https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115920
Bug ID: 115920 Summary: ICE: in tree_to_poly_int64, at tree.cc:3319 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: --- Target: x86_64 ******************************************************************************* The compiler produces an internal error during tree_to_poly_int64 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-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /root/gdbtest/gcc/obj/../gcc/configure --prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240509 (experimental) (GCC) ******************************************************************************* Program: # cat source_code_1.c struct s { int i; char c[]; }; const struct s s = { .c = "0", }; const struct s *const r = &(constexpr struct s) { .c = "1", }; const struct s *const t = &(static struct s) { .c = "2", }; size_t ice(void) { return __builtin_object_size(t, 1); } ******************************************************************************* Command Lines: # gcc source_code_1.c -O2 -Wall -Wextra -pedantic -std=c99 -fstrict-aliasing -Wshadow -Wconversion -Wsign-conversion -Wcast-align -Wformat=2 -Wnull-dereference -Wstrict-overflow=5 -Wdouble-promotion -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wno-gnu-anonymous-struct -Wno-non-standard-layout -Wno-variadic-macros -o source_code_1.o source_code_1.c:7:27: warning: initialization of a flexible array member [-Wpedantic] 7 | const struct s s = { .c = "0", }; | ^~~ source_code_1.c:7:27: note: (near initialization for ‘s.c’) source_code_1.c:7:14: warning: initialization of a flexible array member [-Wpedantic] 7 | const struct s s = { .c = "0", }; | ^ source_code_1.c:7:14: note: (near initialization for ‘s’) source_code_1.c:8:29: error: ‘constexpr’ undeclared here (not in a function) 8 | const struct s *const r = &(constexpr struct s) { .c = "1", }; | ^~~~~~~~~ source_code_1.c:8:38: error: expected ‘)’ before ‘struct’ 8 | const struct s *const r = &(constexpr struct s) { .c = "1", }; | ~ ^~~~~~~ | ) source_code_1.c:8:49: error: expected ‘,’ or ‘;’ before ‘{’ token 8 | const struct s *const r = &(constexpr struct s) { .c = "1", }; | ^ source_code_1.c:8:62: warning: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic] 8 | const struct s *const r = &(constexpr struct s) { .c = "1", }; | ^ source_code_1.c:9:53: warning: initialization of a flexible array member [-Wpedantic] 9 | const struct s *const t = &(static struct s) { .c = "2", }; | ^~~ source_code_1.c:9:53: note: (near initialization for ‘(anonymous).c’) source_code_1.c:9:43: warning: initialization of a flexible array member [-Wpedantic] 9 | const struct s *const t = &(static struct s) { .c = "2", }; | ^ source_code_1.c:9:43: note: (near initialization for ‘(anonymous)’) source_code_1.c:9:46: warning: ISO C forbids storage class specifiers in compound literals before C23 [-Wpedantic] 9 | const struct s *const t = &(static struct s) { .c = "2", }; | ^ source_code_1.c:11:1: error: unknown type name ‘size_t’ 11 | size_t ice(void) | ^~~~~~ source_code_1.c:1:1: note: ‘size_t’ is defined in header ‘<stddef.h>’; this is probably fixable by adding ‘#include <stddef.h>’ +++ |+#include <stddef.h> 1 | source_code_1.c: In function ‘ice’: source_code_1.c:13:12: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion] 13 | return __builtin_object_size(t, 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ source_code_1.c:13:12: internal compiler error: in tree_to_poly_int64, at tree.cc:3313 0x8bd846 tree_to_poly_int64(tree_node const*) /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:3313 0x8bd846 tree_to_poly_int64(tree_node const*) /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:3311 0x13e4767 component_ref_size(tree_node*, special_array_member*) /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:13344 0x115ea3d decl_init_size(tree_node*, bool) /root/gdbtest/gcc/obj/../gcc/gcc/tree-object-size.cc:482 0x115fcb5 addr_object_size /root/gdbtest/gcc/obj/../gcc/gcc/tree-object-size.cc:557 0xb2b4e4 fold_builtin_object_size /root/gdbtest/gcc/obj/../gcc/gcc/builtins.cc:11638 0xb2b4e4 fold_builtin_2 /root/gdbtest/gcc/obj/../gcc/gcc/builtins.cc:10667 0xb2b4e4 fold_builtin_n /root/gdbtest/gcc/obj/../gcc/gcc/builtins.cc:10779 0xd7d736 gimplify_call_expr /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:4099 0xd64036 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:17856 0xd63f4e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:17990 0xd87e47 gimplify_modify_expr /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:6506 0xd63cb6 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:17887 0xd663a6 gimplify_stmt(tree_node**, gimple**) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:7581 0xd744e0 gimplify_and_add(tree_node*, gimple**) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:515 0xd744e0 gimplify_return_expr /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:1910 0xd6448c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:18149 0xd663a6 gimplify_stmt(tree_node**, gimple**) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:7581 0xd674a6 gimplify_bind_expr /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:1641 0xd64064 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /root/gdbtest/gcc/obj/../gcc/gcc/gimplify.cc:18088 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. ******************************************************************************* Also ICE on trunk, compiler explorer:https://godbolt.org/z/dP97Wc9bK *******************************************************************************