------- Comment #39 from rguenth at gcc dot gnu dot org 2007-03-01 09:50 ------- One key point to notice is that the transformation looks at ARG0 op CST where arg0 and cst don't necessarily have to have the same type (arg0 is reduced from op0 by STRIP_SIGN_NOPS), so effectively this folds
(Base_Type)x > 10 (where 10 is supposed to be in Base_Type in the interesting case) based on the value range of x! Now, it also folds x > 10 with 10 in the derived type but out-of-range constant (created wrongly by fold, as you noticed). It should be possible to check whether 10 is in of a derived type and in that case not doing the folding, which is probably way easier than fixing all of fold not to generate those constants. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911