public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56152] New: explicit template instantiation of protected template function redeclared as public fails
@ 2013-01-30 15:29 froydnj at gcc dot gnu.org
2013-01-30 20:24 ` [Bug c++/56152] " daniel.kruegler at googlemail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: froydnj at gcc dot gnu.org @ 2013-01-30 15:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56152
Bug #: 56152
Summary: explicit template instantiation of protected template
function redeclared as public fails
Classification: Unclassified
Product: gcc
Version: 4.4.7
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: froydnj@gcc.gnu.org
Compiling the following testcase:
enum Flavor {
A,
B
};
template<enum Flavor F>
class C
{
protected:
template<typename T>
static T f(T x)
{
if (F == A)
return x;
else
return ~x;
}
};
class AC : public C<A>
{
private:
typedef C<A> super;
public:
using super::f;
};
unsigned int
explicit_variable(unsigned int x)
{
unsigned int (*func)(unsigned int) = AC::f<unsigned int>;
return func(x);
}
unsigned int
explicit_call_instantiation(unsigned int x)
{
return AC::f<unsigned int>(x);
}
unsigned int
implicit_call_instantiation(unsigned int x)
{
return AC::f(x);
}
produces:
template-instantiation-bug.cpp: In function ‘unsigned int
explicit_variable(unsigned int)’:
template-instantiation-bug.cpp:11:12: error: ‘static T C<F>::f(T) [with T =
unsigned int, Flavor F = (Flavor)0u]’ is protected
template-instantiation-bug.cpp:32:44: error: within this context
template-instantiation-bug.cpp:11:12: error: ‘static T C<F>::f(T) [with T =
unsigned int, Flavor F = (Flavor)0u]’ is protected
template-instantiation-bug.cpp:32:44: error: within this context
template-instantiation-bug.cpp:11:12: error: ‘static T C<F>::f(T) [with T =
unsigned int, Flavor F = (Flavor)0u]’ is protected
template-instantiation-bug.cpp:32:44: error: within this context
It is not obvious to me that this is the right answer, given that both
explicit_call_instantiation and implicit_call_instantiation work.
All versions of GCC that I've tested reject the testcase (4.4 - 4.8). Clang
(2.8 - 3.2) accepts the testcase. MSVC version 9 rejects it. My MSVC version
10 installation appears to be busted, or I'd test it there too.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/56152] explicit template instantiation of protected template function redeclared as public fails
2013-01-30 15:29 [Bug c++/56152] New: explicit template instantiation of protected template function redeclared as public fails froydnj at gcc dot gnu.org
@ 2013-01-30 20:24 ` daniel.kruegler at googlemail dot com
2013-08-21 10:49 ` paolo.carlini at oracle dot com
2021-12-11 8:53 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-01-30 20:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56152
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-01-30 20:24:06 UTC ---
GCC 4.8.0 trunk behaves similar. I think the situation is currently not clear
by the language. It looks like a manifestation of
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1551
to me. Especially bullet 3 in the P/R looks relevant to me.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/56152] explicit template instantiation of protected template function redeclared as public fails
2013-01-30 15:29 [Bug c++/56152] New: explicit template instantiation of protected template function redeclared as public fails froydnj at gcc dot gnu.org
2013-01-30 20:24 ` [Bug c++/56152] " daniel.kruegler at googlemail dot com
@ 2013-08-21 10:49 ` paolo.carlini at oracle dot com
2021-12-11 8:53 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-21 10:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56152
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-08-21
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/56152] explicit template instantiation of protected template function redeclared as public fails
2013-01-30 15:29 [Bug c++/56152] New: explicit template instantiation of protected template function redeclared as public fails froydnj at gcc dot gnu.org
2013-01-30 20:24 ` [Bug c++/56152] " daniel.kruegler at googlemail dot com
2013-08-21 10:49 ` paolo.carlini at oracle dot com
@ 2021-12-11 8:53 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-11 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56152
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2013-08-21 00:00:00 |2021-12-11
Keywords| |rejects-valid
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
class C
{
protected:
template<typename T>
static T f(T x){return x;}
};
struct AC : C
{
using C::f;
};
unsigned int (*func)(unsigned int) = AC::f;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-11 8:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30 15:29 [Bug c++/56152] New: explicit template instantiation of protected template function redeclared as public fails froydnj at gcc dot gnu.org
2013-01-30 20:24 ` [Bug c++/56152] " daniel.kruegler at googlemail dot com
2013-08-21 10:49 ` paolo.carlini at oracle dot com
2021-12-11 8:53 ` 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).