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++/69472] New: [concepts] constraint ignored on constrained member template of a class template


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

            Bug ID: 69472
           Summary: [concepts] constraint ignored on constrained member
                    template of a class template
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr
  Target Milestone: ---

PR69288 may be related as it also observes some differences in how a
constrained template behaves depending on whether it is a member template of a
class template or not. On the other hand it involves an ambiguity and a
non-dependent template parameter, whereas this does not. Although I should
point out that the actual code I produced this testcase from did originally
exhibit an ambiguity.

Using 6.0.0 20160122, testcase compiled with:
    g++-trunk -std=c++1z main.cpp

results in:
    main.cpp: In instantiation of 'struct enclosing<void>::member<int>':
    main.cpp:35:35:   required from here
    main.cpp:25:9: error: static assertion failed

Full testcase:

template<typename>
constexpr bool foo = true;

template<>
constexpr bool foo<int> = false;

template<typename T>
struct non_member {};

template<typename T>
    requires foo<T>
struct non_member<T> {
    static_assert( foo<T> );
};

template<typename>
struct enclosing {
    template<typename T>
    struct member {};

    template<typename T>
        requires foo<T>
    struct member<T> {
        // error: static_assertion failed
        static_assert( foo<T> );
    };
};

int main()
{
    // fine
    non_member<int> {};

    // blows up
    enclosing<void>::member<int> {};
}

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