https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127343

            Bug ID: 127343
           Summary: ICE (Segmentation fault) in
                    check_postconditions_in_redecl during template
                    substitution with -fcontracts
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Keywords: c++-contracts, c++26, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thisisandrew0110 at gmail dot com
  Target Milestone: ---

Created attachment 65568
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65568&action=edit
Preprocessed source

Compilation command:
g++ -freport-bug -fcontracts -std=c++26 -Wall -Wextra main.cpp

Minimal reproducer (main.cpp):
----------------------------------------
void foo(auto... args) pre(false) {}

int main() {
  foo();
  return 0;
}
----------------------------------------

Compiler output:
main.cpp: In substitution of ‘template<class ... auto:1> void foo(auto:1 ...)
[with auto:1 = {}]’:
main.cpp:4:6:   required from here
    4 |   foo();
      |   ~~~^~
main.cpp:1:6: internal compiler error: Segmentation fault
    1 | void foo(auto... args) pre(false) {}
      |      ^~~
0x249dcef diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2496941 internal_error(char const*, ...)
        ???:0
0x1138a77 crash_signal(int)
        ???:0
0x883b34 check_postconditions_in_redecl(tree_node*, tree_node*)
        ???:0
0xa15ac4 tsubst_function_decl(tree_node*, tree_node*, int, tree_node*, bool)
        ???:0
0xa10ead tsubst_decl(tree_node*, tree_node*, int, bool)
        ???:0
0xa2065e instantiate_template(tree_node*, tree_node*, int)
        ???:0
0xa25d5f fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0x812931 add_template_candidate_real(z_candidate**, tree_node*, tree_node*,
tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed> const*, tree_node*,
tree_node*, tree_node*, int, tree_node*, unification_kind_t, bool, int) [clone
.isra.0]
        ???:0
0x813995 add_candidates(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed> const*, tree_node*, tree_node*, bool, tree_node*, tree_node*, int,
z_candidate**, int) [clone .part.0]
        ???:0
0x818dae perform_overload_resolution(tree_node*, vec<tree_node*, va_gc,
vl_embed> const*, z_candidate**, bool*, int)
        ???:0
0x81b769 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xa553fe finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0x9a03ac cp_parser_postfix_expression(cp_parser*, bool, bool, bool, bool,
cp_id_kind*)
        ???:0
0x99ba8d cp_parser_unary_expression(cp_parser*, cp_id_kind*, bool, bool, bool)
        ???:0
0x97ebf0 cp_parser_cast_expression(cp_parser*, bool, bool, bool, cp_id_kind*)
        ???:0
0x97fbef cp_parser_binary_expression(cp_parser*, bool, bool, bool,
cp_parser_prec, cp_id_kind*)
        ???:0
0x9809ac cp_parser_assignment_expression(cp_parser*, cp_id_kind*, bool, bool)
        ???:0
0x985477 cp_parser_expression(cp_parser*, cp_id_kind*, bool, bool, bool)
        ???:0
0x989add cp_parser_expression_statement(cp_parser*, tree_node*)
        ???:0
/nix/store/3vwrw0n1f88n8637fnbn8gpmxzfmpwap-gcc-16.2.0/libexec/gcc/x86_64-unknown-linux-gnu/16.2.0/cc1plus
-quiet -D_GNU_SOURCE -idirafter
/nix/store/qwi863qp79xkdm2yw3xzjh73dpg9qh67-glibc-2.42-84-dev/include
-idirafter
/nix/store/3vwrw0n1f88n8637fnbn8gpmxzfmpwap-gcc-16.2.0/lib/gcc/x86_64-unknown-linux-gnu/16.2.0/include-fixed
-isystem /nix/store/bg2bp1zmii5spb2hkgv5xn6mzva7nx9r-gdb-17.2/include -isystem
/nix/store/bg2bp1zmii5spb2hkgv5xn6mzva7nx9r-gdb-17.2/include main.cpp -quiet
-dumpdir a- -dumpbase main.cpp -dumpbase-ext .cpp -mno-omit-leaf-frame-pointer
-mtls-dialect=gnu2 -mtune=generic -march=x86-64 -Wall -Wextra -std=c++26
-fno-omit-frame-pointer -freport-bug -fcontracts -frandom-seed=8chwyz65q2 -o
/tmp/cc24JoCQ.s
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/cc2yt55X.out file, please attach this to
your bugreport.

Reply via email to