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

            Bug ID: 101677
           Summary: [11 Regression] Concept with use of incomplete type
                    succeeds on GCC 10.3.0, fails on GCC 11 onward
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joeloser93 at gmail dot com
  Target Milestone: ---

A concept that uses an incomplete type in testing the well-formedness of
calling a function template is well-formed in GCC 10.3.0, but fails in GCC 11
onward (including trunk at the time of this writing).

For example, consider the following:

template<class T>
concept C_bug_with_forward_decl = requires(T& t){
    t.template f<class S>();
};

struct good {
    template<class T> auto f() -> void {}
};

static_assert(C_bug_with_forward_decl<good>); // works in GCC 10.3.0, fails on
GCC 11 onward

This bug can be worked around by using a complete type instead when defining
the concept. For example:

struct U{};
template<class T>
concept C_workaround = requires(T& t){
    t.template f<U>();
};

static_assert(C_workaround<good>); // works on GCC 10.3.0 and GCC 11 onward

See it live at https://godbolt.org/z/h7GzqGhYn

Reply via email to