* namespace and class within with similar name
@ 2008-08-04 23:03 Alexander Werth
2008-08-05 11:44 ` John Love-Jensen
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Werth @ 2008-08-04 23:03 UTC (permalink / raw)
To: gcc-help
Hi,
I have the following code and I wonder why C++ complains.
namespace S {
class L;
class S;
}
using namespace S;
class C {
void m(::S::L *l) {};
};
$ g++ main.5.cpp
main.5.cpp:12: error: âstruct S::S::Lâ has not been declared
Shouldn't it be clear that I wan't to access class L in
namespace S and not some L of class S in namespace S ?
Couriously I only get this error on some compilers:
gcc 4.1 and gcc 4.2.3 produce this error while
gcc 3.2.2 and xlc work as expected.
Any idea besides complaining about why I want to do this at all ? ;)
Alexander
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: namespace and class within with similar name
2008-08-04 23:03 namespace and class within with similar name Alexander Werth
@ 2008-08-05 11:44 ` John Love-Jensen
0 siblings, 0 replies; 2+ messages in thread
From: John Love-Jensen @ 2008-08-05 11:44 UTC (permalink / raw)
To: Alexander Werth, GCC-help
Hi Alexander,
> Shouldn't it be clear that I wan't to access class L in
> namespace S and not some L of class S in namespace S ?
It appears that when you injected the identifiers from namespace S into the
global namespace, the ::S::L is ambiguous between namespace S and class S
which both are (now) in the global namespace.
The compiler is going down the class S path.
I think that's a bug.
Not that I can cite chapter/verse of ISO 14882, rather I just tested against
the EDG front end, and EDG accepted the code. (I have strong confidence
that the EDG front end is fully compliant with ISO 14882.)
> Any idea besides complaining about why I want to do this at all ? ;)
I think you should file a bug. Maybe it will get fixed in GCC 4.4, and if
not, probably by 4.5.
http://gcc.gnu.org/bugs.html
Sincerely,
--Eljay
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-05 11:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-04 23:03 namespace and class within with similar name Alexander Werth
2008-08-05 11:44 ` John Love-Jensen
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).