https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127057
Bug ID: 127057
Summary: internal compiler error: tree check: expected class
'constant', have 'binary' (bit_and_expr) in
pointer_int_sum, at c-family/c-common.cc:3497
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: lu.maltsis at postgrad dot manchester.ac.uk
Target Milestone: ---
int a(char *b, int c) {
return b[4 * 2336755557723404846 - 5UL & 4294967295 != c];
}
gives
```
<source>: In function 'a':
<source>:2:16: warning: integer overflow in expression of type 'long int'
results in '-9099721842815932232' [-Woverflow]
2 | return b[4 * 2336755557723404846 - 5UL & 4294967295 != c];
| ^
<source>:2:5: internal compiler error: tree check: expected class 'constant',
have 'binary' (bit_and_expr) in pointer_int_sum, at c-family/c-common.cc:3497
2 | return b[4 * 2336755557723404846 - 5UL & 4294967295 != c];
| ^~~~~~
0x2843a68 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x28386ab internal_error(char const*, ...)
???:0
0x93bad4 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xaa7483 build_binary_op(unsigned long, tree_code, tree_node*, tree_node*,
bool)
???:0
0xaabf83 build_array_ref(unsigned long, tree_node*, tree_node*)
???:0
0xb17050 c_parse_file()
???:0
0xb9c9d9 c_common_parse_file()
???:0
/cefs/2b/2bfe0fa0c60788c805993609_gcc-trunk-20260825/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/2b/2bfe0fa0c60788c805993609_gcc-trunk-20260825/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
<source> -quiet -dumpdir /app/ -dumpbase output.c -dumpbase-ext .c -masm=intel
-mtune=generic -march=x86-64 -g -fdiagnostics-color=always -fno-verbose-asm -o
/app/output.s
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
```
triggers on trunk
(https://github.com/gcc-mirror/gcc/commit/d57755dd2dcb3e1bf6d72bc2aeaa22a7a027a5c7)
https://godbolt.org/z/rdhG1nobP
triggers on assertions builds of stable version, at least all the way back to
10.4 https://godbolt.org/z/6o6fjnsr5