User account creation filtered due to spam.

Bug 37553 - [4.3/4.4 Regression] ICE in build_c_cast
Summary: [4.3/4.4 Regression] ICE in build_c_cast
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.1
: P2 normal
Target Milestone: 4.4.0
Assignee: Doug Gregor
Keywords: ice-on-valid-code
Depends on:
Blocks: 50800
  Show dependency treegraph
Reported: 2008-09-17 06:25 UTC by Alexander E. Patrakov
Modified: 2015-04-16 19:07 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 4.2.4
Known to fail:
Last reconfirmed: 2008-09-24 04:37:04


Note You need to log in before you can comment on or make changes to this bug.
Description Alexander E. Patrakov 2008-09-17 06:25:08 UTC
This code triggers an ICE in gcc-4.3.1 on i686 when compiled with g++:

typedef unsigned int ui32;
__extension__ typedef unsigned long long int ui64;

typedef ui32 __attribute__ ((__may_alias__)) ui32a;
typedef ui64 __attribute__ ((__may_alias__)) ui64a;

union u_u32
  ui32a v;
} __attribute__ ((__may_alias__));

union u_u64
  ui64a v;
    union u_u32 lo32, hi32;
  } u;
} __attribute__ ((__may_alias__));

out_long (ui64 longVal)
  if ((*(union u_u64 *) &longVal).u.lo32.v < 0x10000000ul)
      if ((ui32) ((*(union u_u64 *) &longVal).u.lo32.v) < 0x4000u)
          /* do something useful */

longs3.c: In function 'void out_long(ui64)':
longs3.c:24: internal compiler error: in build_c_cast, at cp/typeck.c:5631
Comment 1 Andrew Pinski 2008-09-17 21:02:56 UTC
I get a different internal compiler error: internal compiler error: canonical types differ for identical types ui32 and ui32a
Please submit a full bug report,
with preprocessed source if appropriate.
See <> for instructions.

Comment 2 Richard Biener 2008-09-20 14:49:19 UTC
ui32 and ui32a are identical (they are identical in middle-end terms), but
ui32 * and ui32a * would not be identical.  Sounds weird, but the way
may_alias is designed make it so.  A 32bit target is required to trigger
the ICE.
Comment 3 Doug Gregor 2008-09-24 06:01:04 UTC
Patch here:
Comment 4 dgregor 2008-10-14 15:05:17 UTC
Subject: Bug 37553

Author: dgregor
Date: Tue Oct 14 15:03:51 2008
New Revision: 141111

2008-10-14  Douglas Gregor  <>

       PR c++/37553
       * tree.c (build_type_attribute_qual_variant): Hash on the
       unqualified type, and don't overwrite an existing
       (type_hash_eq): Make the TYPE_NAME of the types significant, to
       allow distinguishing between wchar_t and its underlying type. This
       also means that we'll retain a little more typedef information.

2008-10-14  Douglas Gregor  <>

       PR c++/37553
       * g++.dg/ext/alias-canon2.C: New.


Comment 5 Doug Gregor 2008-10-14 16:03:41 UTC
Fixed on mainline