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

            Bug ID: 113683
           Summary: explicit template instantiation wrongly checks private
                    base class accessibility
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: schaumb at gmail dot com
  Target Milestone: ---

The compiler wrongly checks that the (private) base class is accessible when
explicit template instantiation happens. (standard: C++20)

It shouldn't, see https://eel.is/c++draft/temp.spec#general-6

template<const auto* v>
struct I{};

struct A {};

class B : A {
    static const B b;
};

I need to instantiate the B::b object address with const A*.
But this line is failing:

template struct I<static_cast<const A*>(&B::b)>; // fails on static_cast


Simplified "real" example code: https://godbolt.org/z/zj9co5bMh

Reply via email to