sizeof on const

Tal Agmon Tal.Agmon@nsc.com
Thu Nov 27 19:48:00 GMT 2003


Hi,

I'm currently working on a new compiler port, which should be submitted to
GNU soon.
We're still waiting for the FSF assignment papers completion, so the legal
process are in progress.

We're using a 16-bit architecture, which doesn't support the 'long long'
type.
I have noticed that the following line yields different results for
different GCC (for our target) versions :
      long a = sizeof(0100000000000);

GCC 2.95  : a=4;
GCC 3.2.3 : a=8;
GCC 3.3.2 : a=2;

The ISO-C standard does not implicitly relates to the case of 'sizeof'
applied on a constant, but indicates that the value of the result
is implementation-defined.

Can someone explain the reason for the differences ?

Regards,
      Tomer
                tomer.levi@nsc.com
National Semi-Conductor





More information about the Gcc mailing list