https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117806

            Bug ID: 117806
           Summary: ICE: in composite_type_internal, at c/c-typeck.cc:825
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---

*******************************************************************************
The compiler produces an internal error during get_len when compiling the
provided code with the specified options. 
The issue can also be reproduced on Compiler Explorer.

*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-241127/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/root/gdbtest/gcc/gcc-241127
--enable-languages=c,c++ --disable-multilib --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20241127 (experimental) (GCC) 
*******************************************************************************
Program:
# cat bug.c


struct Test {
  double D __attribute__((packed,aligned(4)));
  short X;
};

struct Test {
  double D  __attribute__((packed,aligned(4)));
  short X;
};

struct {
  char x;
  struct Test t;
} b = { 1, { 2, 3}};

struct Test {
  double D __attribute__((packed,aligned(4)));
  short X;
} x;

struct {
  char x;
  struct Test t;
} b = { 1, { 2, 3}};

struct Test {
  double D __attribute__((packed,aligned(4)));
  short X;
} x;

struct {
  char x;
  struct Test t;
} b = { 1, { 2, 3}};

struct Test {
  double D __attribute__((packed,aligned(4)));
  short X;
} x;

struct {
  char x;
  struct Test t;
} b = { 1, { 2, 3}};


*******************************************************************************
Command Lines:
# gcc bug.c -funroll-loops -flto -O2 -Wall -Wextra -fno-strict-aliasing -fwrapv
-g -fsanitize=address  -c -o bug.o

<source>:24:3: error: conflicting types for 'b'; have 'struct <anonymous>'
   24 | } b = { 1, { 2, 3}};
      |   ^
<source>:14:3: note: previous definition of 'b' with type 'struct <anonymous>'
   14 | } b = { 1, { 2, 3}};
      |   ^
<source>:34:3: error: conflicting types for 'b'; have 'struct <anonymous>'
   34 | } b = { 1, { 2, 3}};
      |   ^
<source>:14:3: note: previous definition of 'b' with type 'struct <anonymous>'
   14 | } b = { 1, { 2, 3}};
      |   ^
<source>:39:1: internal compiler error: in composite_type_internal, at
c/c-typeck.cc:825
   39 | } x;
      | ^
0x25c00b5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x25d6da5 internal_error(char const*, ...)
        ???:0
0x9b7794 fancy_abort(char const*, int, char const*)
        ???:0
0xa093c2 composite_type(tree_node*, tree_node*)
        ???:0
0x9de78a pushdecl(tree_node*)
        ???:0
0x9f3211 start_decl(c_declarator*, c_declspecs*, bool, tree_node*, bool,
unsigned int*)
        ???:0
0xa7900b c_parse_file()
        ???:0
0xaf5a59 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/bs61PsxGP

*******************************************************************************

Reply via email to