public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64216] New: Function template can access private sub class without being friend
@ 2014-12-08 0:52 yyc1992 at gmail dot com
2014-12-08 10:02 ` [Bug c++/64216] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: yyc1992 at gmail dot com @ 2014-12-08 0:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64216
Bug ID: 64216
Summary: Function template can access private sub class without
being friend
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yyc1992 at gmail dot com
The following code compiles on g++ 4.9.2 while it shouldn't.
Accessing private members and access in non-templates are properly checked.
However, a function template can actually access any private sub-class without
being a friend. This problem exist for all standards I've tried
((gnu|c)++(98|03|11|14))
The code is properly rejected by clang++ 3.5.0.
```
//
class C {
struct T2 {
};
static void f() {}
};
template<typename T>
static inline void
f(T)
{
// C::f(); // This generates an error correctly
C::T2 __attribute__((unused)) v2; // This does not generate an error
}
int
main()
{
// C::T2 v2; // This also generates an error correctly
f(1);
return 0;
}
```
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/64216] Function template can access private sub class without being friend
2014-12-08 0:52 [Bug c++/64216] New: Function template can access private sub class without being friend yyc1992 at gmail dot com
@ 2014-12-08 10:02 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-08 10:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64216
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2014-12-08
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Almost certainly a duplicate of one of the bugs linked to PR59002,
it looks nearly identical to PR41437
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-08 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08 0:52 [Bug c++/64216] New: Function template can access private sub class without being friend yyc1992 at gmail dot com
2014-12-08 10:02 ` [Bug c++/64216] " redi 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).