public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113683] New: explicit template instantiation wrongly checks private base class accessibility
@ 2024-01-31 15:26 schaumb at gmail dot com
2024-01-31 17:57 ` [Bug c++/113683] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: schaumb at gmail dot com @ 2024-01-31 15:26 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/113683] explicit template instantiation wrongly checks private base class accessibility
2024-01-31 15:26 [Bug c++/113683] New: explicit template instantiation wrongly checks private base class accessibility schaumb at gmail dot com
@ 2024-01-31 17:57 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-31 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113683
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
MSVC rejects this also for the same reason:
<source>(10): error C2243: 'static_cast': conversion from 'const B *' to 'const
A *' exists, but is inaccessible
clang accepts it though ...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-31 17:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31 15:26 [Bug c++/113683] New: explicit template instantiation wrongly checks private base class accessibility schaumb at gmail dot com
2024-01-31 17:57 ` [Bug c++/113683] " pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).