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

            Bug ID: 67545
           Summary: [concepts] Failure to properly substitute template
                    parameters into requires-clause
           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 36323
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36323&action=edit
Preprocessed test case

r227603 fails to compile this correct TU:

#include <stl2/detail/swap.hpp>

struct I {
  int operator*() const;
};

template <class R>
using Ref = decltype(*std::declval<R>());

template <class U = I>
  requires !__stl2::Swappable<Ref<I>, Ref<I>>()
static constexpr bool bar() { return true; }

template <class U = I>
  requires !__stl2::Swappable<Ref<U>, Ref<U>>()
static constexpr bool foo() { return true; }

static_assert(bar()); // Fine
static_assert(foo()); // Error

with error:

~/gcc6/bin/g++ -std=gnu++1z -I ~/cmcstl2/include -I ~/cmcstl2/meta/include
foo.cpp -c
foo.cpp:19:19: error: cannot call function ‘constexpr bool foo() [with U = I]’
 static_assert(foo()); // Error
                   ^
foo.cpp:16:23: note:   constraints not satisfied
 static constexpr bool foo() { return true; }
                       ^
foo.cpp:16:23: note:   ‘! Swappable<Ref<U>, Ref<U> >()’ evaluated to false

Despite the fact that the requirements on foo and bar are functionally
equivalent, the call to bar succeeds whilst the call to `bar` fails to compile.
I conjecture that the substitution of template parameters into foo's requires
clause is not working correctly.

Reply via email to