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

            Bug ID: 78752
           Summary: [concepts] ICE with constrained variadic member
                    function
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tcbrindle at gmail dot com
  Target Milestone: ---

Created attachment 40287
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40287&action=edit
Short test case causing ICE

Test code:

#include <type_traits>

template <class T, class U>
concept bool Same = std::is_same<T, U>::value;

struct test {
    template <Same<int>... Ints>
    void func(Ints... ints) {}
};

int main()
{
    test t;
    t.func(1, 2, 3);
}

Compiling with g++ -fconcepts -std=c++17 gives:

concepts_ice.cpp: In substitution of 'template<class ... Ints>  requires 
Same<Ints, int>... void test::func(Ints ...) [with Ints = {int, int, int}]':
concepts_ice.cpp:14:19:   required from here
concepts_ice.cpp:9:10: internal compiler error: in tsubst_constraint, at
cp/constraint.cc:1957
     void func(Ints... ints) {}
          ^~~~

concepts_ice.cpp:9:10: internal compiler error: Abort trap: 6
g++-6: internal compiler error: Abort trap: 6 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.


----

If we replace the member function definition with the more verbose

    struct test {
        template <class... Ints>
            requires (Same<Ints, int> && ...)
        void func(Ints... ints) {}
    };

then this compiles correctly. Replacing it with the abbreviated syntax

    struct test {
        void func(Same<int>... ints) {}
    };

gives "constraints not satisfied" when calling `test{}.func(1, 2, 3);`, but no
ICE.

This seems to be specific to member functions: the free function

    template <Same<int>... Ints>
    void func(Ints... ints) {}

    func(1, 2, 3);

works as expected, but the abbreviated version

    void func(Same<int>... ints) {}

still reports constraints not satisfied.

Reply via email to