This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/55559] [4.6/4.7/4.8 Regression] Marshalling double through union with inlines, incorrect behavior with -O2


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-03 12:30:20 UTC ---
We ask fold_unary to fold

fold_unary_ignore_overflow_loc (loc=2147483655, code=FIX_TRUNC_EXPR, 
    type=0x7ffff6d17690, op0=0x7ffff6e23858)
    at /space/rguenther/src/svn/trunk/gcc/fold-const.c:8363
(gdb) call debug_tree (type)
 <integer_type 0x7ffff6d17690 unsigned int public unsigned SI
    size <integer_cst 0x7ffff6d1a0c0 type <integer_type 0x7ffff6d170a8
bitsizetype> constant 32>
    unit size <integer_cst 0x7ffff6d1a0e0 type <integer_type 0x7ffff6d17000
sizetype> constant 4>
    align 32 symtab 0 alias set -1 canonical type 0x7ffff6d17690 precision 32
min <integer_cst 0x7ffff6d1a100 0> max <integer_cst 0x7ffff6d1a0a0 4294967295>
    pointer_to_this <pointer_type 0x7ffff6d270a8>>
(gdb) call debug_tree (op0)
 <real_cst 0x7ffff6e23858
    type <real_type 0x7ffff6d17f18 double sizes-gimplified DF
        size <integer_cst 0x7ffff6d02d40 constant 64>
        unit size <integer_cst 0x7ffff6d02d60 constant 8>
        align 64 symtab 0 alias set -1 canonical type 0x7ffff6d17f18 precision
64
        pointer_to_this <pointer_type 0x7ffff6d1f150>>
    constant -1.0e+0>

which ends up in fold_convert_const_int_from_real which returns
0 with TREE_OVERFLOW set.

Note that you end up converting the double -1.0 to unsigned which according
to C99 6.3.1.4 ends up invoking undefined behavior.

GCC's behavior is not ill-defined, your testcase is.  That behavior changed
is fine as it is unsefined.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]