public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95468] New: ICE in expression sfinae
@ 2020-06-01 19:57 kab at acm dot org
  2020-06-02  5:56 ` [Bug c++/95468] " marxin at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kab at acm dot org @ 2020-06-01 19:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95468
           Summary: ICE in expression sfinae
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kab at acm dot org
  Target Milestone: ---

The code below gets ICE with gcc9.2 and gcc7.5 (the versions I have immediately
available to test with).

The error message is:
internal compiler error: unexpected expression '(bool)(true)' of kind cast_expr

To test:
g++ -c -std=c++11 ice-expr-sfinae.cpp

Strangely, using a namespace scope function template instead of a static member
function template works fine.  To demonstrate that, compile with
-DTRIGGER_ICE=0.

----- ice-expr-sfinae.cpp -----

#include <type_traits>

#ifndef TRIGGER_ICE
#define TRIGGER_ICE 1
#endif

#if TRIGGER_ICE

struct slip {
  template<bool C> static constexpr bool condition() { return C; }
};

template<typename std::enable_if<slip::condition<bool(true)>(), int>::type = 0>
static bool dispatch() { return true; }

bool test() {
  return dispatch();
}

#else

// No ICE if the condition function is at namespace scope.

template<bool C> static constexpr bool noslip_condition() { return C; }

template<typename std::enable_if<noslip_condition<bool(true)>(), int>::type =
0>
static bool dispatch() { return true; }

bool test() {
  return dispatch();
}

#endif

----- end of file -----

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

end of thread, other threads:[~2021-05-14 13:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 19:57 [Bug c++/95468] New: ICE in expression sfinae kab at acm dot org
2020-06-02  5:56 ` [Bug c++/95468] " marxin at gcc dot gnu.org
2020-06-03  1:09 ` kab at acm dot org
2020-06-03 15:23 ` [Bug c++/95468] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
2020-06-03 15:48 ` ppalka at gcc dot gnu.org
2021-01-14  8:57 ` rguenth at gcc dot gnu.org
2021-02-12 23:37 ` ppalka at gcc dot gnu.org
2021-02-23 14:40 ` cvs-commit at gcc dot gnu.org
2021-02-23 14:42 ` [Bug c++/95468] [8/9/10 " ppalka at gcc dot gnu.org
2021-03-31 12:33 ` cvs-commit at gcc dot gnu.org
2021-04-21 21:09 ` [Bug c++/95468] [8/9 " cvs-commit at gcc dot gnu.org
2021-05-14 13:58 ` [Bug c++/95468] [8 " jakub 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).