------- Comment #5 from amylaar at gcc dot gnu dot org 2006-05-02 18:21 ------- (In reply to comment #4) > (In reply to comment #1) > > In 3.x, double -> char/int conversion was done consistently with the > > documented > > behaviour of integer -> signed integer type conversion. > > http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Integers-implementation.html#Integers-implementation. > > That has nothing to do with float -> integer type conversion.
Actually, it has, in two ways: - The wording is inexact. You could argue that 128. is an integer in floating point representation and thus covered by this clause. Although from the context, it appears that that was not the intent. - When the return statement is changed to "return (signed char)(int) d;", the clause applies, and indeed the behaviour becomes consistent. Having different semantics when you add an itermediate cast to int before casting to signed char is somewhat surprising. (I.e. although a conforming implementation, it does not follow the rule of least surprise.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27394