This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/66218] New: [c++-concepts] "inconsistent deduction for âautoâ" with a partial-concept-id in a deduction constraint


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]