------- Comment #12 from gpiez at web dot de  2010-06-12 08:46 -------
I am closing this, as it isn't a gcc bug, as it behaves according to the
standard.

The bug is in the standard, as it mandates

f<1,1>                  // ok
f<CHAR_MAX, CHAR_MAX>() // error
g<INT_MAX, INT_MAX>()   // no error, but undefined behaviuour

f(char, char)           // error
g(int, int)             // ok

which is inconsistent and surprising. C++0x should really have got rid of the
implicit integer promotion. Wasn't the intent of the implicit promotion to be
able to write 

char a,b,c,d;
a = b*c/d;

and get a correct result even if b*c > CHAR_MAX? I believe nobody does write
code like this anymore, and even if, you could simply say "undefined behaviour"
;-) It doesn't work for ints anyway.

Instead I have now an implicit integer promotion which forces me to use an
explicit cast in compound initializers, where narrowing conversion isn't
allowed, while in a simple assignment of course it is allowed (or else a hell
would break loose... ). Why not make -Wconversion an error, at least this would
be consistent ;-)


-- 


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

Reply via email to