public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59151] New: gcc name lookup for friend template finds class outside of
@ 2013-11-16 12:27 gafunchal at gmail dot com
2013-11-16 16:33 ` [Bug c++/59151] gcc name lookup for friend template finds class outside of enclosing namespace redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: gafunchal at gmail dot com @ 2013-11-16 12:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59151
Bug ID: 59151
Summary: gcc name lookup for friend template finds class
outside of
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gafunchal at gmail dot com
template<typename T>
class Class1;
namespace B {
template<typename U>
class Class2 {
template<typename V>
friend class Class1;
private:
int something_private;
};
}
template<typename T>
class Class1
{
void error() {
B::Class2 b;
b.something_private = 42;
}
};
I orignally thought this to be a clang bug, it seems to actually be a problem
in gcc incorrectly accepting this code.
Richard Smith mentions in http://llvm.org/bugs/show_bug.cgi?id=17950:
--8<--
7.3.1.2/3:
"If the name in a friend declaration is neither qualified nor a template-id and
the declaration is a function or an elaborated-type-specifier, the lookup to
determine whether the entity has been previously declared shall not consider
any scopes outside the innermost enclosing namespace."
Therefore a (not-yet-declared) 'template<typename V> class B::Class1;' is
befriended, not the global Class1.
-->8--
So gcc should require replacing the friend declaration by:
template<typename V>
friend class ::Class1;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/59151] gcc name lookup for friend template finds class outside of enclosing namespace
2013-11-16 12:27 [Bug c++/59151] New: gcc name lookup for friend template finds class outside of gafunchal at gmail dot com
@ 2013-11-16 16:33 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-16 16:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59151
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Looks like a dup of PR 56820
*** This bug has been marked as a duplicate of bug 56820 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-16 16:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-16 12:27 [Bug c++/59151] New: gcc name lookup for friend template finds class outside of gafunchal at gmail dot com
2013-11-16 16:33 ` [Bug c++/59151] gcc name lookup for friend template finds class outside of enclosing namespace 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).