https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66218
Bug ID: 66218
Summary: [c++-concepts] "inconsistent deduction for ‘auto’"
with a partial-concept-id in a deduction constraint
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Casey at Carter dot net
Target Milestone: ---
Created attachment 35576
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35576&action=edit
testcase.cpp
Compiling this correct program with r223444 of the c++-concepts branch:
#include <type_traits>
template <class T, class U>
concept bool Same =
std::is_same<T, U>::value;
template <class T>
concept bool C =
requires(T t) {
{ t } -> Same<T>;
};
template <class>
constexpr bool f() { return false; }
template <C>
constexpr bool f() { return true; }
static_assert(f<char>(), "");
static_assert(f<int>(), "");
static_assert(f<double>(), "");
int main() {}
produces errors:
bug2.cpp:19:22: error: inconsistent deduction for ‘auto’: ‘char’ and then ‘int’
static_assert(f<int>(), "");
^
bug2.cpp:19:1: error: static assertion failed:
static_assert(f<int>(), "");
^
bug2.cpp:20:25: error: inconsistent deduction for ‘auto’: ‘char’ and then
‘double’
static_assert(f<double>(), "");
^
bug2.cpp:20:1: error: static assertion failed:
static_assert(f<double>(), "");
^
It appears that the result of the first deduction is stored in memory instead
of being discarded.