------- Comment #2 from lopezibanez at gmail dot com  2006-09-16 01:38 -------
Richard, could you tell which bug report do you mean?

The -Wconversion warnings does not apply to this case. Wconversion warns about
the effect of adding a prototype, not about sign conversions. 

Anyway, I still don't understand where is the bug. Unary minus applied to
unsigned (what typically is the type of sizeof()) gives:

" `2^n - i', where `n' is the number of bits in the
unsigned type." [1]

So actually -sizeof(int) is 4294967292 (assuming sizeof(int) is 4). This number
fits well in a signed long long. However, it doesn't fit in a signed int, and
thus, it wraps around and produces -4.

The -Wcoercion flag provided by the Wcoercion project [2] warns for the
wrap-around as:

pr26298.c:15: warning: coercion as 'int' alters 'unsigned int' constant value


[1] http://gcc.gnu.org/ml/gcc/1999-06n/msg00754.html
[2] http://gcc.gnu.org/wiki/Wcoercion


-- 

lopezibanez at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lopezibanez at gmail dot
                   |                            |com, rguenth at gcc dot gnu
                   |                            |dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298

Reply via email to