Bug 117479 - ICE on x86_64-linux-gnu: in cxx_eval_constant_expression, at cp/constexpr.cc:8448 with vector_size
Summary: ICE on x86_64-linux-gnu: in cxx_eval_constant_expression, at cp/constexpr.cc:...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 15.0
: P5 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2024-11-07 10:56 UTC by Anonymous
Modified: 2024-11-07 20:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-11-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anonymous 2024-11-07 10:56:06 UTC
Compiler Explorer: https://godbolt.org/z/W8v9x3bde

*******************************************************************************
gcc version:
Using built-in specs.
COLLECT_GCC=/home/software/gcc-trunk/bin/gcc
COLLECT_LTO_WRAPPER=/home/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --disable-bootstrap --enable-checking=yes --prefix=/home/software/gcc-trunk --enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib --enable-coverage
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20241107 (experimental) (GCC)

*******************************************************************************
Program:
$ cat mutant.C
struct {
  int a;
  __attribute__((vector_size(4))) int c { a };
} constexpr b {
};

*******************************************************************************
Command Lines:
$ gcc mutant.C
mutant.C:5:1: internal compiler error: in cxx_eval_constant_expression, at cp/constexpr.cc:8448
    5 | }
      | ^
0x5cdf4f4 internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:518
0x5c807b6 fancy_abort(char const*, int, char const*)
        ../../gcc/gcc/diagnostic.cc:1696
0xf7d3b4 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.cc:8448
0xf6a9c4 cxx_eval_indirect_ref
        ../../gcc/gcc/cp/constexpr.cc:5995
0xf78f14 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.cc:7874
0xf60932 cxx_eval_component_reference
        ../../gcc/gcc/cp/constexpr.cc:4598
0xf79a0a cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.cc:8047
0xf65f51 cxx_eval_bare_aggregate
        ../../gcc/gcc/cp/constexpr.cc:5369
0xf79f46 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.cc:8107
0xf65f51 cxx_eval_bare_aggregate
        ../../gcc/gcc/cp/constexpr.cc:5369
0xf79f46 cxx_eval_constant_expression
        ../../gcc/gcc/cp/constexpr.cc:8107
0xf8102a cxx_eval_outermost_constant_expr
        ../../gcc/gcc/cp/constexpr.cc:8880
0xf84107 maybe_constant_init_1
        ../../gcc/gcc/cp/constexpr.cc:9391
0xf84244 cxx_constant_init(tree_node*, tree_node*)
        ../../gcc/gcc/cp/constexpr.cc:9417
0x169a16b store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ../../gcc/gcc/cp/typeck2.cc:910
0x109512a check_initializer
        ../../gcc/gcc/cp/decl.cc:7880
0x10a122f cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int, cp_decomp*)
        ../../gcc/gcc/cp/decl.cc:8933
0x1383414 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.cc:23919
0x1364c5a cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.cc:16165
0x1364376 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.cc:15984
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.
Comment 1 Marek Polacek 2024-11-07 15:58:38 UTC
Even GCC 5 ICEs.
Comment 2 Drea Pinski 2024-11-07 18:22:41 UTC
I think this code is valid though.

Slightly better/easier testcase:
```
typedef __attribute__((vector_size(sizeof(int)))) int v1si;

struct s1 {
  int a;
  v1si c { a };
};
s1 b1;
constexpr s1 b{1};
```

I think we don't treat vector constructors as possible constexpr.
Comment 3 Drea Pinski 2024-11-07 18:26:10 UTC
Also doing:
```
v1si c { 1 };
```
Works.