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

            Bug ID: 94517
           Summary: incorrect use of enable_if compiles but should not
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Following code https://godbolt.org/z/Zfazdt
compiles with GCC
and does not compile (as expected) if the class becomes a template:
https://godbolt.org/z/2KRRin

It should not compile in the first case either because there is no template
parameter being deduced.

Sources:

#include <functional>

struct NoDefault
{
    NoDefault() = delete;
};

// compiles while should not
struct X : public NoDefault
{
    template 
    <
        std::enable_if_t
        <   
            std::is_default_constructible_v
            <
                NoDefault
            >
        >* = nullptr
    > X() : NoDefault{}
    {
    }
};

template <class T>
struct Y : public NoDefault
{
    template 
    <
        std::enable_if_t
        <   
            std::is_default_constructible_v
            <
                NoDefault
            >
        >* = nullptr
    > Y() : NoDefault{}
    {
    }
};

// expectedly does not compile
template struct Y<int>;

Reply via email to