public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104470] New: internal compiler error: Segmentation fault compiling std::variant with -std=c++20
@ 2022-02-09 18:25 serpent7776 at gmail dot com
  2022-02-10  1:09 ` [Bug c++/104470] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: serpent7776 at gmail dot com @ 2022-02-09 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104470
           Summary: internal compiler error: Segmentation fault compiling
                    std::variant with -std=c++20
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: serpent7776 at gmail dot com
  Target Milestone: ---

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

I encountered an internal compiler error while compiling the following code in
c++20 mode (no other flags are needed):

#include <variant>

template <typename T>
struct Foo
{
        T value;
};

template <typename T>
struct Bar
{
        T value;
};

template <typename T>
using V = std::variant<Foo<T>, Bar<T>>;

int main()
{
        V e = Foo("a");
}

When I switch to c++17 mode compiler does not crash.

I tested it on g++ 10.3.0 on FreeBSD 12.3-RELEASE-p1, but I can also reproduce
it on trunk version here https://godbolt.org/z/vn5Ws14Ma

Full error:

# g++10 -std=c++20 ice.ii
In file included from ice.cpp:1:
/usr/local/lib/gcc10/include/c++/variant: In substitution of 'template<class
... _Types> template<class _Tp, class> using __accepted_type =
std::variant<_Types>::__to_type<__accepted_index<_Tp> > [with _Tp = _Tp&&;
<template-parameter-2-2> = typename std::enable_if<std::variant<Foo<T>, Bar<T>
>::__not_self<_Tp&&>, void>::type; _Types = {Foo<T>, Bar<T>}]':
ice.cpp:20:15:   required from here
/usr/local/lib/gcc10/include/c++/variant:1335:36: internal compiler error:
Segmentation fault
 1335 |  using __accepted_type = __to_type<__accepted_index<_Tp>>;
      |                                    ^~~~~~~~~~~~~~~~~~~~
libbacktrace could not find executable to open

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

end of thread, other threads:[~2023-07-07 10:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 18:25 [Bug c++/104470] New: internal compiler error: Segmentation fault compiling std::variant with -std=c++20 serpent7776 at gmail dot com
2022-02-10  1:09 ` [Bug c++/104470] " pinskia at gcc dot gnu.org
2022-02-10  6:02 ` pinskia at gcc dot gnu.org
2022-02-10  8:18 ` pinskia at gcc dot gnu.org
2022-04-22 11:57 ` max.kanold@nu-cost.com
2022-04-22 15:03 ` mpolacek at gcc dot gnu.org
2022-04-22 15:10 ` [Bug c++/104470] [10/11/12 Regression] " mpolacek at gcc dot gnu.org
2022-04-26 22:34 ` jason at gcc dot gnu.org
2022-04-29 21:25 ` [Bug c++/104470] [10/11/12/13 " cvs-commit at gcc dot gnu.org
2022-05-04 21:59 ` cvs-commit at gcc dot gnu.org
2022-05-15 16:29 ` [Bug c++/104470] [10/11/12 " cvs-commit at gcc dot gnu.org
2022-06-28 10:48 ` [Bug c++/104470] [10/11 " jakub at gcc dot gnu.org
2023-07-07 10:42 ` [Bug c++/104470] [11 " rguenth 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).