It is my belief that this code:
#include <stdio.h>
struct foo {
char array[1024];
};
int main() {
fprintf(stderr, "sizeof(foo::array): %zd\n", sizeof(foo::array));
}
Is valid C++. g++ compiles it just fine with -ansi -pedantic. However, compiling with Intel's icc 12.1.3 I get:
error #288: a nonstatic member reference must be relative to a specific object
Is it my mistake or is icc doing the wrong thing re: the C++ spec?
It is a compiler bug or maybe the compiler was issued before this feature was adopted in the Standard.
According to the C++ Standard (5.1 Primary expressions)
13 An id-expression that denotes a non-static data member or non-static member function of a class can only be used:
— if that id-expression denotes a non-static data member and it appears in an unevaluated operand.
[ Example:
struct S {
int m;
};
int i = sizeof(S::m); // OK
int j = sizeof(S::m + 42); // OK
—end example ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With