public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "serpent7776 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104470] New: internal compiler error: Segmentation fault compiling std::variant with -std=c++20
Date: Wed, 09 Feb 2022 18:25:02 +0000	[thread overview]
Message-ID: <bug-104470-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2022-02-09 18:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 18:25 serpent7776 at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104470-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).