public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109160] New: [Valid code] Constraint on deduced NTTP from method call causes ICE/Segfault.
@ 2023-03-16 20:15 vincent_saulue at hotmail dot fr
  2023-03-17 14:23 ` [Bug c++/109160] " ppalka at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vincent_saulue at hotmail dot fr @ 2023-03-16 20:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109160
           Summary: [Valid code] Constraint on deduced NTTP from method
                    call causes ICE/Segfault.
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent_saulue at hotmail dot fr
  Target Milestone: ---

To my knowledge, the following code is well-formed c++20, and compiles with
clang and MSVC.
- g++ 11.x & 12.x: this code causes a segmentation fault.
- g++ 10.x & 13.0(godbolt trunk): this code causes an ICE.

The issue is reproducible on godbolt: https://godbolt.org/z/bxbeTa69f

Code:
```
struct Traits {
    static constexpr bool value = true;
};

template<typename T, typename Traits>
concept cBarOf = Traits::value;

template<typename Traits, auto bar>
struct Foo {
    template<cBarOf<Traits> auto rhsBar> // <-- this concept causes ICE.
    void doNothing(Foo<Traits, rhsBar> const&);
};

void someFunction() {
    Foo<Traits, 0> lhs{};
    lhs.doNothing(lhs);
}
```

Compiler output on my local machine:
```
# g++ --version
g++-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0

# g++ -std=c++20 source.cpp
source.cpp: In substitution of ‘template<auto [requires ::cBarOf<<placeholder>,
Traits>] rhsBar> void Foo<Traits, 0>::doNothing(const Foo<Traits, rhsBar>&)
[with auto [requires ::cBarOf<<placeholder>, Traits>] rhsBar = <missing>]’:
source.cpp:16:18:   required from here
source.cpp:16:18: internal compiler error: Segmentation fault
   16 |     lhs.doNothing(lhs);
      |     ~~~~~~~~~~~~~^~~~~
0xd910e3 crash_signal
        ../../src/gcc/toplev.cc:322
0x7f546f77251f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x801af0 iterative_hash_template_arg(tree_node*, unsigned int)
        ../../src/gcc/cp/pt.cc:1786
0x6e9d99 sat_hasher::hash(sat_entry*)
        ../../src/gcc/cp/constraint.cc:2491
0x6e9d99 hash_table<sat_hasher, false, xcallocator>::find_slot(sat_entry*
const&, insert_option)
        ../../src/gcc/hash-table.h:435
0x6e9d99 satisfaction_cache::satisfaction_cache(tree_node*, tree_node*,
sat_info)
        ../../src/gcc/cp/constraint.cc:2584
0x6ec446 satisfy_atom
        ../../src/gcc/cp/constraint.cc:2914
0x6ec446 satisfy_constraint_r
        ../../src/gcc/cp/constraint.cc:3023
0x6ecf33 satisfy_normalized_constraints
        ../../src/gcc/cp/constraint.cc:3048
0x6eaa53 satisfy_nondeclaration_constraints
        ../../src/gcc/cp/constraint.cc:3130
0x6eaa53 constraint_satisfaction_value
        ../../src/gcc/cp/constraint.cc:3285
0x6ecfbb constraints_satisfied_p(tree_node*, tree_node*)
        ../../src/gcc/cp/constraint.cc:3317
0x80c2c2 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ../../src/gcc/cp/pt.cc:30349
0x8166d9 unify
        ../../src/gcc/cp/pt.cc:24272
0x816791 unify
        ../../src/gcc/cp/pt.cc:24476
0x82d48e try_class_unification
        ../../src/gcc/cp/pt.cc:23437
0x81633b unify
        ../../src/gcc/cp/pt.cc:24513
0x82bfa3 unify_one_argument
        ../../src/gcc/cp/pt.cc:22650
0x814938 type_unification_real
        ../../src/gcc/cp/pt.cc:22773
0x831b0a fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ../../src/gcc/cp/pt.cc:22096
```

Output of godbolt's gcc(trunk):
```
# g++ --version
g++
(Compiler-Explorer-Build-gcc-0c061da91a3657afdb3fac68e4595af685909a1a-binutils-2.38)
13.0.1 20230316 (experimental)

# g++ -std=c++20
<source>: In substitution of 'template<auto [requires ::cBarOf<<placeholder>,
Traits>] rhsBar> void Foo<Traits, 0>::doNothing(const Foo<Traits, rhsBar>&)
[with auto [requires ::cBarOf<<placeholder>, Traits>] rhsBar = <missing>]':
<source>:16:18:   required from here
<source>:16:18: internal compiler error: tree check: accessed elt 1 of
'tree_vec' with 0 elts in hash, at cp/constraint.cc:2571
   16 |     lhs.doNothing(lhs);
      |     ~~~~~~~~~~~~~^~~~~
0x23b52ae internal_error(char const*, ...)
        ???:0
0x94819b tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ???:0
0xafc7c4 sat_hasher::hash(sat_entry*)
        ???:0
0xaf7adf satisfaction_cache::satisfaction_cache(tree_node*, tree_node*,
sat_info)
        ???:0
0xafb922 constraints_satisfied_p(tree_node*, tree_node*)
        ???:0
0xc79882 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ???:0
0xcb0831 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xaac75a build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xc5e0df c_parse_file()
        ???:0
0xd9ac69 c_common_parse_file()
        ???:0
```

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-09 12:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 20:15 [Bug c++/109160] New: [Valid code] Constraint on deduced NTTP from method call causes ICE/Segfault vincent_saulue at hotmail dot fr
2023-03-17 14:23 ` [Bug c++/109160] " ppalka at gcc dot gnu.org
2023-04-01 16:01 ` cvs-commit at gcc dot gnu.org
2023-04-01 16:02 ` ppalka at gcc dot gnu.org
2023-04-01 16:02 ` ppalka at gcc dot gnu.org
2023-04-14 13:33 ` vincent_saulue at hotmail dot fr
2023-05-08 12:26 ` rguenth at gcc dot gnu.org
2023-05-09 12:57 ` cvs-commit at gcc dot gnu.org
2023-05-09 12:58 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).