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

Meador Inge <meadori at codesourcery dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|4.6.4                       |4.8.0

--- Comment #1 from Meador Inge <meadori at codesourcery dot com> 2012-03-23 
02:29:46 UTC ---
Actually I found a smaller repro that also triggers in trunk:

typedef unsigned long * ul_ptr;

constexpr void * a = (void*) ((ul_ptr)(((ul_ptr)0x01000010)[14]))[0];

The problem happens when 'cxx_eval_indirect_ref' is presented with an
indirect reference expression that looks like:

<indirect_ref 0xf7dd6018
    type <integer_type 0xf7c524e0 long unsigned int public unsigned SI
        size <integer_cst 0xf7c3b5cc constant 32>
        unit size <integer_cst 0xf7c3b5e8 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0xf7c524e0 precision 32
min <integer_cst 0xf7c3b984 0> max <integer_cst 0xf7c3b968 4294967295>
        pointer_to_this <pointer_type 0xf7dc9cc0>>

    arg 0 <nop_expr 0xf7dd6000
        type <pointer_type 0xf7dc9d20 ul_ptr type <integer_type 0xf7c524e0 long
unsigned int>
            unsigned SI size <integer_cst 0xf7c3b5cc 32> unit size <integer_cst
0xf7c3b5e8 4>
            align 32 symtab 0 alias set -1 canonical type 0xf7dc9cc0>

        arg 0 <indirect_ref 0xf7da3fc0 type <integer_type 0xf7c524e0 long
unsigned int>

            arg 0 <integer_cst 0xf7cabe54 constant 16777288>
            /home/meadori/etc/bugs/issue13031.cpp:3:63>
        /home/meadori/etc/bugs/issue13031.cpp:3:68>
    /home/meadori/etc/bugs/issue13031.cpp:3:68>

It calls into 'cxx_fold_indirect_ref' to fold the indirect reference operand
and
ends up stripping the NOP cast ending up with:

<indirect_ref 0xf7da3fc0
    type <integer_type 0xf7c524e0 long unsigned int public unsigned SI
        size <integer_cst 0xf7c3b5cc constant 32>
        unit size <integer_cst 0xf7c3b5e8 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0xf7c524e0 precision 32
min <integer_cst 0xf7c3b984 0> max <integer_cst 0xf7c3b968 4294967295>
        pointer_to_this <pointer_type 0xf7dc9cc0>>

    arg 0 <integer_cst 0xf7cabe54 type <pointer_type 0xf7dc9d20 ul_ptr>
constant 16777288>

which, of course, fails the 'gcc_assert (POINTER_TYPE_P (subtype));' assert
in 'cxx_fold_indirect_ref'.

I would like to work out a patch for this one.  Any tips would be appreciated.

Reply via email to