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

            Bug ID: 117293
           Summary: SFINAE in class partial specialization "leaks" its
                    side-effects
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.cencora at gmail dot com
  Target Milestone: ---

It seems like the deprecation warning is kept even if triggered due to failed
substitution in context of class partial specialization.
In other SFINAE contexts (e.g. a dummy template param of Bar constructor) the
deprecation warning is correctly not reported.

Following code compiles without a problem on clang.

> cat a.cpp

template <typename T>
T declval();

template<typename Src, typename Dst, typename>
struct overload_set;

template<typename Src, typename Dst>
struct overload_set<Src, Dst, decltype(void(Dst{declval<Src>()}))>
{
    using type = void;
};

struct string
{};

struct Foo
{
    [[deprecated("dupa")]] Foo(const string&)
    {};
};

struct Bar
{
    template <typename U, typename overload_set<const U&, Foo, void>::type* =
nullptr>
    Bar(const U&);

    Bar(const string&);
};

int main()
{
    string a;

    Bar b{a};
}

> g++ -std=c++17 -Wall -Wextra -Werror a.cpp


This was reduced from custom implementation of variant, but I see that
libstdc++ variant uses similar impl with _Build_FUN so may be affected as well.

Reply via email to