https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80562
Bug ID: 80562
Summary: ICE using if constexpr with nonconstant expression in
function template
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
Build: GCC v8.0.0 (built from source 20170429)
The following code:
----
struct T {
constexpr auto foo() { return false; }
};
template <class MustBeTemplate>
constexpr auto bf(T t) {
if constexpr(t.foo()) {
return false;
}
return true;
}
----
Yields the following error, and ends with mmap() failing to allocate memory:
<source>: In function 'constexpr auto bf(T)':
<source>:7:25: internal compiler error: in cxx_eval_constant_expression, at
cp/constexpr.c:4312
if constexpr(t.foo()) {
^
mmap: Cannot allocate memory
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler exited with result code 1
----
see https://godbolt.org/g/tTpkeD