https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126345
Bug ID: 126345
Summary: ICE when using contract with empty parameter pack
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hello at nathanbaggs dot co.uk
Target Milestone: ---
struct Foo
{
template <class... Args>
auto go(Args &&...args) -> void
pre(true)
{
}
};
int main()
{
Foo f{};
f.go();
}
<source>: In substitution of 'template<class ... Args> void Foo::go(Args&& ...)
[with Args = {}]':
<source>:14:9: required from here
14 | f.go();
| ~~~~^~
<source>:4:10: internal compiler error: Segmentation fault
4 | auto go(Args &&...args) -> void
| ^~
0x226a6a8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x226399b internal_error(char const*, ...)
???:0
0x8893b4 check_postconditions_in_redecl(tree_node*, tree_node*)
???:0
0x9fbffa instantiate_template(tree_node*, tree_node*, int)
???:0
0xa0b0c1 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x8169e7 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
???:0
0xa36999 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0x9c751d c_parse_file()
???:0
0xaf3a69 c_common_parse_file()
???:0
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/bin/../libexec/gcc/x86_64-linux-gnu/16.1.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/bin/../lib/gcc/x86_64-linux-gnu/16.1.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++26
-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
Godbolt: https://godbolt.org/z/orfMr4TKP
This does not generate an ICE if you either:
- Remove pre(true)
- Pass an argument to go() when calling e.g. f.go(1);
This appears to be an issue when calling a variadic templated function, with a
pre-condition, when the parameter pack is empty