public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94628] New: segfault decltype
@ 2020-04-16 21:41 roland at rschulz dot eu
  2020-04-16 21:55 ` [Bug c++/94628] " mpolacek at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: roland at rschulz dot eu @ 2020-04-16 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

end of thread, other threads:[~2022-05-27  8:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 21:41 [Bug c++/94628] New: segfault decltype roland at rschulz dot eu
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

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).