From: krishna on
Doesn't the context provide enough information (to the compiler) when
it sees "sizeof int" and interpret it the same way as "sizeof x"?

-Krishna.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Seungbeom Kim on
krishna wrote:
> Doesn't the context provide enough information (to the compiler) when
> it sees "sizeof int" and interpret it the same way as "sizeof x"?

I'm not a compiler expert, but I could think of some tricky cases.
Consider the compiler saw a stream of tokens:

sizeof int * * E

It could be sizeof(int *) * E, or sizeof(int) * (* E). (Of course,
E of an arithmetic type would make only the former case well-formed,
and E of a pointer type would make only the latter well-formed, and
these two cannot happen at the same time.)

On the other hand, I don't understand why the Standard allows "sizeof x"
without parentheses. It's much clearer with mandatory parentheses.
(I have to admit that I often write "fgets(buf, sizeof buf, stdin)" :D)

--
Seungbeom Kim

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]