https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818
Bug ID: 111818 Summary: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: 141242068 at smail dot nju.edu.cn Target Milestone: --- When compile below program with GCC-14 and option `-O1`, GCC-14 crashes: ``` #define DUMMY_VALUE 0x12345678 static void foo(const volatile unsigned int x, void *p) { __builtin_memcpy(p, &x, sizeof x); __builtin_memcpy(p, &x, sizeof x); } void bar(int type, void *number) { switch (type) { case 1: foo(DUMMY_VALUE, number); break; case 7: foo(0, number); break; case 8: foo(0, number); break; case 9: foo(0, number); break; } } ``` The crash reproducer: https://godbolt.org/z/7sP8zc3Kc And the full stack dump: ``` <source>: In function 'foo': <source>:3:23: warning: passing argument 2 of '__builtin_memcpy' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] 3 | __builtin_memcpy(p, &x, sizeof x); | ^~ <source>:3:23: note: expected 'const void *' but argument is of type 'const volatile unsigned int *' <source>:4:23: warning: passing argument 2 of '__builtin_memcpy' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] 4 | __builtin_memcpy(p, &x, sizeof x); | ^~ <source>:4:23: note: expected 'const void *' but argument is of type 'const volatile unsigned int *' during RTL pass: expand In function 'foo', inlined from 'bar' at <source>:9:11: <source>:3:3: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733 3 | __builtin_memcpy(p, &x, sizeof x); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0x22ff3ee internal_error(char const*, ...) ???:0 0x8a8243 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*) ???:0 0xc9ab0e set_mem_attributes_minus_bitpos(rtx_def*, tree_node*, int, poly_int<1u, long>) ???:0 0xcc6c35 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ???:0 0xcd3083 store_expr(tree_node*, rtx_def*, int, bool, bool) ???:0 0xcd4d66 expand_assignment(tree_node*, tree_node*, bool) ???: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. ```