https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120199
Bug ID: 120199
Summary: ICE in type_dependent_expression_p when using
__builtin_addressof on templated function
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mario.rodriguezb1 at um dot es
Target Milestone: ---
Using __builtin_addressof on a templated function results in an internal
compiler error (ICE) in type_dependent_expression_p, even when the function is
not actually instantiated or used.
If code is slighly change ICE can change, and version where it occurs too.
```
#include <iostream>
template<size_t N>
void kernel1() {
__builtin_addressof(kernel1);
}
```
Stack dump
```
<source>: In function 'void kernel1()':
<source>:4:37: internal compiler error: in type_dependent_expression_p, at
cp/pt.cc:29272
4 | __builtin_addressof(kernel1);
| ^
0x293b2d5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x29552f6 internal_error(char const*, ...)
???:0
0xad6166 fancy_abort(char const*, int, char const*)
???:0
0xd74277 finish_expr_stmt(tree_node*)
???:0
0xcfa203 c_parse_file()
???:0
0xe5cbd9 c_common_parse_file()
???: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.
Compiler returned: 1
```
Example ICE 1 (SINCE 7.1):
https://gcc.godbolt.org/z/EWGMoej7o
Example ICE 2 (SINCE 7.1):
https://gcc.godbolt.org/z/hWoxP4PE6
Example ICE 3 (ONLY IN TRUNK):
https://gcc.godbolt.org/z/qb8Kf131c