g++ gives an ICE on the following source (no optimization required):

$ ~/gcc/build/gcc/cc1plus -quiet x.cc
x.cc: In function 'C f(const C&)':
x.cc:6: internal compiler error: in check_pointer_types_r, at gimplify.c:4198
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
$


It's crashing here:

    case ADDR_EXPR:
      ptype = TREE_TYPE (t);
      otype = TREE_TYPE (TREE_OPERAND (t, 0));
      dtype = TREE_TYPE (ptype);
      if (!cpt_same_type (otype, dtype))
        {
          /* &array is allowed to produce a pointer to the element, rather than
             a pointer to the array type.  We must allow this in order to
             properly represent assigning the address of an array in C into
             pointer to the element type.  */
          gcc_assert (TREE_CODE (otype) == ARRAY_TYPE
                      && POINTER_TYPE_P (ptype)
                      && cpt_same_type (TREE_TYPE (otype), dtype));
          break;
        }
 
because OTYPE isn't an ARRAY_TYPE:

(gdb) call debug_tree(otype)
 <reference_type 0x400be2b8
    type <record_type 0x400b6bc8 C addressable tree_2 needs-constructing type_1 
type_5 BLK
        size <integer_cst 0x400243d8 constant invariant 32>
        unit size <integer_cst 0x40024168 constant invariant 4>
        align 32 symtab 0 alias set -1
        fields <field_decl 0x400b932c _vptr.C type <pointer_type 0x40094e0c>
            unsigned virtual SI file x.cc line 2 size <integer_cst 0x400243d8 
32> unit size <integer_cst 0x40024168 4>
            align 32 offset_align 128
            offset <integer_cst 0x40024180 constant invariant 0>
            bit offset <integer_cst 0x40024948 constant invariant 0> context 
<record_type 0x400b6bc8 C> arguments <integer_cst 0x40024180 0> chain 
<type_decl 0x400b6d98 C>>
       needs-constructor X() X(constX&) this=(X&) n_parents=0 use_template=0 
interface-unknown
        pointer_to_this <pointer_type 0x400b9000> reference_to_this 
<reference_type 0x400be2b8> chain <type_decl 0x400b6cb0 C>>
    unsigned SI size <integer_cst 0x400243d8 32> unit size <integer_cst 
0x40024168 4>
    align 32 symtab 0 alias set -1>

Environment:
System: Linux karma 2.6.8.1 #20 Mon Sep 13 23:48:47 EDT 2004 i686 i686 i386 
GNU/Linux
Architecture: i686

        <machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/sss/gcc/gcc/configure --prefix=/usr/local/gcc 
--enable-threads=posix --enable-long-long --enable-languages=c,c++,f95

How-To-Repeat:



Compile the following:

------------------------------------------------------
struct C
{
  virtual void operator()() const;
};

C f(const C& c)
{
  C cc (c);
  cc();
  return cc;
}

------------------------------------------------------
------- Additional Comments From sss at d0mino03 dot fnal dot gov  2004-12-15 
22:26 -------
Fix:
        <how to correct or work around the problem, if known (multiple lines)>

-- 
           Summary: ICE in check_pointer_types_r
           Product: gcc
           Version: 0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sss at d0mino03 dot fnal dot gov
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to