https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128120
Bug ID: 128120
Summary: internal compiler error: tree check: expected
function_decl, have var_decl in has_attribute, at
c-family/c-attribs.cc:6461
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 0599jiangyc at gmail dot com
Target Milestone: ---
The following code:
```c
int v;
int b = __builtin_has_attribute (v, pure);
```
Output:
```
<source>:2:1: internal compiler error: tree check: expected function_decl, have
var_decl in has_attribute, at c-family/c-attribs.cc:6461
2 | int b = __builtin_has_attribute (v, pure);
| ^~~
0x28d2218 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x28c6e5b internal_error(char const*, ...)
???:0
0x9481b2 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xb6af30 c_parse_file()
???:0
0xbf11f9 c_common_parse_file()
???:0
/cefs/b2/b23b881c7b2b30ba33960fa9_gcc-trunk-20261023/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/b2/b23b881c7b2b30ba33960fa9_gcc-trunk-20261023/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
<source> -quiet -dumpdir /app/output.s- -dumpbase example.c -dumpbase-ext .c
-mtune=generic -march=x86-64 -g -fdiagnostics-color=always -fno-verbose-asm
-fsyntax-only -o /dev/null
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.
x86-64 gcc (trunk) - 862ms
```
Trunk: https://godbolt.org/z/5KG86s7cb
Found by https://github.com/fusion-fuzz/fusion-fuzz