The following fails to compile, it would appear that symbols from seperate
namespaces are colliding in error:

[EMAIL PROTECTED] 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);
    }
}
[EMAIL PROTECTED] tmp]$ g++ -v -save-temps -Wall -c test2.cpp
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: /usr/local/share/gcc-3.3.2/configure -march=pentium4 :
(reconfi
gured) /usr/local/share/gcc-3.3.2/configure -march=pentium4 : (reconfigured)
/us
r/local/share/gcc-3.3.2/configure --with-arch=pentium4
Thread model: posix
gcc version 3.3.2
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/cc1plus -E -D__GNUG__=3 -quiet
-
v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -D_GNU_SOURCE
test2.cp
p -Wall test2.ii
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/c++/3.3.2
 /usr/local/include/c++/3.3.2/i686-pc-linux-gnu
 /usr/local/include/c++/3.3.2/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/cc1plus -fpreprocessed test2.ii
-quiet -dumpbase test2.cpp -auxbase test2 -Wall -version -o test2.s
GNU C++ version 3.3.2 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
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'
[EMAIL PROTECTED] tmp]$
[EMAIL PROTECTED] 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);
    }
}
[EMAIL PROTECTED] 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?

If the parameter ns1::x is removed from the signature of ns2::f then there is
no error.  It would appear that the ns1 namespace is being opened up as a
result of the parameter.

The online Comeau C/C++ compiler accepts this particular example.


-- 
           Summary: Unexpected name conflict between symbols
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dwhorton at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25980

Reply via email to