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

            Bug ID: 93551
           Summary: Call from templated function to constrained
                    constructor segfaults when attempting to narrow to
                    bool
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pacoarjonilla at yahoo dot es
  Target Milestone: ---

Minimum code:

>>>>>>>>>>>>>

#include <type_traits>
class Bar { };
struct Foo {
    template <typename P> requires std::is_base_of_v<Bar, P>
    Foo(P const&);
};
template <typename P>
Foo fun(P const& arg) {
    (bool)arg;
    return Foo {arg};
}
int main() {
    fun(Bar{});
    return 0;
}

>>>>>>>>>>>>>

On GCC10 git commit 3539fc13172 (2020/02/03)
runnning on intel i7-8700K on OpenSUSE Tumbleweed.

Also confirmed in compiler explorer GCC trunk (godbolt.org, just copy and
paste)


 g++10git --std=c++2a namidevel.cc 
namidevel.cc: In instantiation of ‘Foo fun(const P&) [with P = Bar]’:
namidevel.cc:13:14:   required from here
namidevel.cc:9:5: error: invalid cast from type ‘const Bar’ to type ‘bool’
    9 |     (bool)arg;
      |     ^~~~~~~~~
namidevel.cc:11:1: internal compiler error: Segmentation fault
   11 | }
      | ^
0xfd70bf crash_signal
        ../../gcc/gcc/toplev.c:328
0x9e29a7 pop_tinst_level()
        ../../gcc/gcc/cp/pt.c:10757
0x9fa98f instantiate_decl(tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:25591
0xa2becb instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:25665
0x936033 c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.c:4875
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.

Reply via email to