[Bug c++/25980] Unexpected name conflict between symbols
gdr at cs dot tamu dot edu
gcc-bugzilla@gcc.gnu.org
Thu Jan 26 18:56:00 GMT 2006
------- Comment #2 from gdr at cs dot tamu dot edu 2006-01-26 18:56 -------
Subject: Re: New: Unexpected name conflict between symbols
"dwhorton at gmail dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| The following fails to compile, it would appear that symbols from seperate
| namespaces are colliding in error:
|
| [dhorton@dev228 tmp]$ cat test2.cpp
| namespace ns1 {
| class c {};
| typedef int f;
|
| static c x;
| }
|
| namespace ns2 {
| void f(ns1::c& cc)
| {
| }
|
| void g()
| {
| f(ns1::x);
| }
| }
[...]
| test2.cpp: In function `void ns2::g()':
| test2.cpp:3: error: `ns1::f' is not a function,
| test2.cpp:10: error: conflict with `void ns2::f(ns1::c&)'
| test2.cpp:15: error: in call to `f'
| [dhorton@dev228 tmp]$
| [dhorton@dev228 tmp]$ cat test2.*i*
| # 1 "test2.cpp"
| # 1 "<built-in>"
| # 1 "<command line>"
| # 1 "test2.cpp"
| namespace ns1 {
| class c {};
| typedef int f;
|
| static c x;
| }
|
| namespace ns2 {
| void f(ns1::c& cc)
| {
| }
|
| void g()
| {
| f(ns1::x);
| }
| }
| [dhorton@dev228 tmp]$
|
| I don't see why symbols ns1::f and ns2::f are in conflict here, as when f()
in
| ns2::g is being resolved ns1::f should not be visible, should it?
This is a known issue. Name lookup apply uniformly. In particular,
ADL finds in this case both function and non-function.
Since we don't have (yet) overload set that can include functions and
non-functions, the program is ill-formed. See Core Issue 218
http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_active.html#218
Notice that the last note was quite a long time ago -- before C++03
and now we're in the "extensions" timeframe. There is strong feeling
that name lookup should apply uniformly, and we should also have
overload resolution with function objects included.
I believe there alreay is a PR for this. The proper action is to
suspend it until the issue is completely resolved.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25980
More information about the Gcc-bugs
mailing list