Post Reply 
Undoc'd Feature?
07-31-2022, 01:29 AM (This post was last modified: 07-31-2022 02:17 AM by jte.)
Post: #40
RE: Undoc'd Feature?
(07-09-2022 05:15 AM)Wes Loewer Wrote:  
(07-08-2022 08:32 PM)jte Wrote:  … as C++17 introduces additional sequencing constraints involving assignment operators.

I tried the following on several different C/C++ compilers

Code:
int a=5;
a = a++;
printf(“%d\n”,a);

and they all printed out 5, except for the Microsoft compiler which prints 6. They all claim to be C++20 compliant, so somebody’s wrong.

After reading this, I was meaning to reply, but wanted to first try your code out with a Microsoft compiler myself. While I have been plugging away at some C++ code, that’s been with a Mac here; I have another machine here, running Windows, that has Microsoft compilers installed, but it’s been warm enough [and I've been busy enough…] that I’ve not wanted to boot up multiple heat-spewing desktops simultaneously. (For the past week I’ve also been wearing 95PFE masks almost all the time [just not when eating or brushing teeth…] as a family member has tested positive for covid [but has had only mild symptoms], which certainly doesn’t lessen my perception of the summer heat. [Before this, I assumed the current variants are contagious enough that preventing spread between people living in the same home, sharing a bathroom, etc. was essentially impossible — even with masks etc., but so far I’ve tested negative each day. I had some scientific curiosity as to what would unfold if we maximized mask wearing, and also had some concerns over the uncertainty of “long covid”, so decided to try wearing masks as much as possible.])

To try out some compilations, I placed your sample code into a function, as follows:
Code:
int Wes(int a)
{
a = 5;
a = a++;
return a;
}

When I try that function out with MSVC++ v14.28 / 1928 (x64), optimizations on, I get the following:
Code:
int Wes(int) PROC
        mov     eax, 6
        ret     0
int Wes(int) ENDP

But, if I add “/std:c++17” as a command-line option, I instead get the following:
Code:
int Wes(int) PROC
        mov     eax, 5
        ret     0
int Wes(int) ENDP

So it seems that conformance with this part of the C++17 language does depend on the options given to the Microsoft compiler that I tried.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Undoc'd Feature? - toml_12953 - 07-03-2022, 03:42 AM
RE: Undoc'd Feature? - Wes Loewer - 07-03-2022, 09:14 AM
RE: Undoc'd Feature? - toml_12953 - 07-03-2022, 09:38 AM
RE: Undoc'd Feature? - Wes Loewer - 07-03-2022, 01:16 PM
RE: Undoc'd Feature? - Wes Loewer - 07-03-2022, 01:49 PM
RE: Undoc'd Feature? - toml_12953 - 07-03-2022, 02:18 PM
RE: Undoc'd Feature? - Wes Loewer - 07-03-2022, 06:24 PM
RE: Undoc'd Feature? - Albert Chan - 07-03-2022, 07:09 PM
RE: Undoc'd Feature? - toml_12953 - 07-04-2022, 01:49 AM
RE: Undoc'd Feature? - toml_12953 - 07-04-2022, 09:41 AM
RE: Undoc'd Feature? - Wes Loewer - 07-04-2022, 03:40 PM
RE: Undoc'd Feature? - xerxes - 08-03-2022, 08:17 PM
RE: Undoc'd Feature? - parisse - 07-03-2022, 11:02 AM
RE: Undoc'd Feature? - Wes Loewer - 07-03-2022, 01:03 PM
RE: Undoc'd Feature? - parisse - 07-03-2022, 06:31 PM
RE: Undoc'd Feature? - Wes Loewer - 07-03-2022, 07:34 PM
RE: Undoc'd Feature? - jte - 07-08-2022, 03:15 AM
RE: Undoc'd Feature? - Wes Loewer - 07-08-2022, 05:00 AM
RE: Undoc'd Feature? - jte - 07-08-2022, 08:32 PM
RE: Undoc'd Feature? - Wes Loewer - 07-09-2022, 05:15 AM
RE: Undoc'd Feature? - RPNerd - 07-09-2022, 12:20 PM
RE: Undoc'd Feature? - Albert Chan - 07-09-2022, 05:10 PM
RE: Undoc'd Feature? - Wes Loewer - 07-10-2022, 05:22 AM
RE: Undoc'd Feature? - toml_12953 - 07-10-2022, 10:22 AM
RE: Undoc'd Feature? - RPNerd - 07-10-2022, 12:48 PM
RE: Undoc'd Feature? - Wes Loewer - 07-17-2022, 01:05 PM
RE: Undoc'd Feature? - jte - 07-31-2022, 02:12 AM
RE: Undoc'd Feature? - Wes Loewer - 07-31-2022, 06:43 PM
RE: Undoc'd Feature? - toml_12953 - 07-31-2022, 07:25 PM
RE: Undoc'd Feature? - Wes Loewer - 08-01-2022, 03:48 AM
RE: Undoc'd Feature? - ijabbott - 07-14-2022, 05:22 PM
RE: Undoc'd Feature? - toml_12953 - 07-10-2022, 05:36 PM
RE: Undoc'd Feature? - Albert Chan - 07-10-2022, 05:57 PM
RE: Undoc'd Feature? - Wes Loewer - 07-10-2022, 07:38 PM
RE: Undoc'd Feature? - ijabbott - 07-11-2022, 07:49 PM
RE: Undoc'd Feature? - RPNerd - 07-12-2022, 11:03 AM
RE: Undoc'd Feature? - ijabbott - 07-13-2022, 09:34 PM
RE: Undoc'd Feature? - Wes Loewer - 07-12-2022, 01:49 PM
RE: Undoc'd Feature? - ijabbott - 07-13-2022, 10:12 PM
RE: Undoc'd Feature? - toml_12953 - 07-13-2022, 10:50 PM
RE: Undoc'd Feature? - jte - 07-31-2022 01:29 AM
RE: Undoc'd Feature? - Wes Loewer - 07-31-2022, 10:13 AM
RE: Undoc'd Feature? - OlidaBel - 07-04-2022, 09:11 AM
RE: Undoc'd Feature? - toml_12953 - 07-04-2022, 09:36 AM
RE: Undoc'd Feature? - ctrclckws - 07-13-2022, 12:44 PM
RE: Undoc'd Feature? - Wes Loewer - 07-13-2022, 08:01 PM



User(s) browsing this thread: 4 Guest(s)