public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "roland at rschulz dot eu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94628] New: segfault decltype
Date: Thu, 16 Apr 2020 21:41:39 +0000	[thread overview]
Message-ID: <bug-94628-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 94628
           Summary: segfault decltype
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roland at rschulz dot eu
  Target Milestone: ---

GCC 9.3 and trunk. Internal compiler error: Segmentation fault

#include <type_traits>
#include <utility>

template<int i>
using int_constant = std::integral_constant<int, i>;

template<int I, int...Is, class F, class...Args>
auto select(int i, F&&f, Args&&...args) -> 
    std::common_type_t<decltype(std::forward<F>(f)(int_constant<I>(), 
std::forward<decltype(args)>(args)...)),
                       decltype(std::forward<F>(f)(int_constant<Is>(),
std::forward<decltype(args)>(args)...))...>
{
    if (i == I) return std::forward<F>(f)(int_constant<I>(),
std::forward<Args>(args)...);
    else {
        if constexpr(sizeof...(Is)>0) 
            return select<Is...>(i, std::forward<F>(f),
std::forward<Args>(args)...);
    }
}

int t(int i) {
    return select<0, 1>(i, [](auto x){ return int(x);});
}


No problem if `decltype(args)` is replaced with `Args`. 

https://godbolt.org/z/kPpEK8

             reply	other threads:[~2020-04-16 21:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 21:41 roland at rschulz dot eu [this message]
2020-04-16 21:55 ` [Bug c++/94628] " mpolacek at gcc dot gnu.org
2020-04-17  6:35 ` [Bug c++/94628] [8/9/10 Regression] ICE in invalid_nonstatic_memfn_p at cp/typeck.c:1979 since r9-640-g1268ecc26fc1289b marxin at gcc dot gnu.org
2020-04-17  7:04 ` rguenth at gcc dot gnu.org
2020-04-18 14:41 ` ppalka at gcc dot gnu.org
2020-04-18 14:42 ` ppalka at gcc dot gnu.org
2020-04-18 22:00 ` xerofoify at gmail dot com
2020-04-18 23:36 ` mpolacek at gcc dot gnu.org
2020-04-19 14:42 ` ppalka at gcc dot gnu.org
2020-04-20  4:26 ` xerofoify at gmail dot com
2020-04-20  7:42 ` marxin at gcc dot gnu.org
2020-04-20 18:55 ` xerofoify at gmail dot com
2020-04-20 18:57 ` xerofoify at gmail dot com
2020-04-20 19:10 ` mpolacek at gcc dot gnu.org
2020-04-20 19:26 ` marxin at gcc dot gnu.org
2020-04-20 22:56 ` cvs-commit at gcc dot gnu.org
2020-04-20 22:57 ` [Bug c++/94628] [8/9 " ppalka at gcc dot gnu.org
2021-04-02 14:28 ` ppalka at gcc dot gnu.org
2021-05-04 12:32 ` rguenth at gcc dot gnu.org
2021-05-14  9:53 ` [Bug c++/94628] [9 " jakub at gcc dot gnu.org
2021-06-01  8:17 ` rguenth at gcc dot gnu.org
2022-05-27  8:51 ` 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-94628-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).