[cfe-dev] sizeof(sizeof(...))
Mike Stump
mrs at apple.com
Sat Dec 15 01:31:20 PST 2007
On Dec 14, 2007, at 12:30 PM, Ted Kremenek wrote:
> Does anyone have any insights on the semantics of expressions of the
> form sizeof(sizeof(...))?
As you suspected the argument isn't evaluated because the type of the
argument isn't a variable length array. Put on your recursion hat and
just think about the first bit of the operand....
sizeof (...) has type size_t.
size_t isn't a VLA.
no need to consider anything instead of the (...).
For fun, try the follow on the old gray matter:
struct { char o[n][m]; } foo(int n, int m) { }
int main() {
return sizeof(foo(3,4));
}
:-)
More information about the cfe-dev
mailing list