Or just microsoft's C is not ISO C but some other standard C (if there exists any).
Microsoft Visual C still supports C89 [only] whereas other compilers like gcc/clang etc support C99 too which is the current Standard.
C99 [Section 6.5.17/2
] says
The left operand of a comma operator is evaluated as a void expression; there is a sequence point after its evaluation. Then the right operand is evaluated; the result has its type and value.95
Thus the result of sizeof (0,arr)
would be sizeof(char*)
[due to the implicit lvalue
to rvalue
conversion /automatic decay to pointer type] not 100*sizeof(char)
sizeof(arr)
would have given 100*sizeof(char)
from 6.5.3.4/3
95) A comma operator does not yield an lvalue.
decided that this would be another solution to the above problem, which I tried on Microsoft Visual Studio 2008, but regardless of whether it is compiled as C or C++ code sizeof(0, arr) always yields 4.
C++03 [5.18/1
] Comma Operator
The type and
value of the result are the type and value of the right operand; the result is an lvalue if its right operand is.
So sizeof(0, arr) = sizeof (arr)
and which would be equal to 100* sizeof(char)
and not = sizeof(char*)
.
So MSVC++ is giving incorrect result (in case of C++ code).