https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95728
Bug ID: 95728
Summary: [11 Regression] tree check: expected tree_list, have
error_mark in tsubst_copy_and_build, at cp/pt.c:19594
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: jason at gcc dot gnu.org
Target Milestone: ---
The code below is invalid (attempting to cast const T* to void*) but dies with
an ICE since r11-423:
PR c++/93286 - ICE with __is_constructible and variadic template.
My GCC 10 patch for 93286 fixed the missing piece in tsubst's handling of
lists vs. that in tsubst_copy_and_build, but it would be better to share
the
code between them.
template<typename T>
void
construct(T* p)
{ ::new(static_cast<void*>(p)) T; }
template<typename T>
void
f(const T* t)
{
construct(t);
}
int main()
{
int i[1];
f(i);
}
ice.cc: In instantiation of 'void construct(T*) [with T = const int]':
ice.cc:10:12: required from 'void f(const T*) [with T = int]'
ice.cc:16:6: required from here
ice.cc:4:11: error: invalid 'static_cast' from type 'const int*' to type
'void*'
4 | { ::new(static_cast<void*>(p)) T; }
| ^~~~~~~~~~~~~~~~~~~~~
ice.cc:4:5: internal compiler error: tree check: expected tree_list, have
error_mark in tsubst_copy_and_build, at cp/pt.c:19640
4 | { ::new(static_cast<void*>(p)) T; }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x81ac46 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
/home/jwakely/src/gcc/gcc/gcc/tree.c:9685
0x67d317 tree_check(tree_node*, char const*, int, char const*, tree_code)
/home/jwakely/src/gcc/gcc/gcc/tree.h:3301
0x67d317 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:19640
0xa91287 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:18772
0xa93ab7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:17879
0xa92db1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:18173
0xa90ba1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:17834
0xa90ba1 instantiate_decl(tree_node*, bool, bool)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:25653
0xac281b instantiate_pending_templates(int)
/home/jwakely/src/gcc/gcc/gcc/cp/pt.c:25769
0x9cb4e0 c_parse_final_cleanups()
/home/jwakely/src/gcc/gcc/gcc/cp/decl2.c:4899
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.