C ++ ANSI ISO IEC 14882 2003 Appendix C.1 (p. 668):
Edit: The result of a conditional expression, assignment expression, or comma expression can bean lvalue
Rationale: C ++ is an object-oriented language, focusing more on lvalues. For example, functions may return lvalues.
Impact on the original function: changing the semantics of a well-defined function. Some C expressions that implicitly rely on lvalue-to-rvalue conversions will give different results. For example,
char arr[100]; sizeof(0, arr)
gives 100 in C ++ and sizeof(char*) in C.
...
I read it only today, and I remembered that after a couple of months my friend suggested a problem that should write a function that would return 0 if it was compiled with C ++ and 1 if it was compiled with C I solved it, taking advantage of the fact that in C the structure was in outer space. Therefore, considering this new information, I decided that it would be another solution to the aforementioned problem that I tried in Microsoft Visual Studio 2008, but regardless of whether it is compiled as C or C ++ code sizeof(0, arr) , always it turns out 4. So 2 questions:
1. What is ISO C? Is this the current standard C? This is the only one (I hear that C is developing rapidly) 2. Is this a Microsoft C ++ bug?
TIA
Edit: Sorry you mixed up with the output and edited it:
c ++ c language-lawyer visual-studio-2008 lvalue-to-rvalue
Armen Tsirunyan
source share