c++/2127: namespace problems
reichelt@igpm.rwth-aachen.de
reichelt@igpm.rwth-aachen.de
Wed Feb 28 12:16:00 GMT 2001
>Number: 2127
>Category: c++
>Synopsis: namespace problems
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Wed Feb 28 12:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Volker Reichelt
>Release: gcc version 3.0 20010227 (prerelease)
>Organization:
>Environment:
mips-sgi-irix6.5
>Description:
Compiling the following lines of code
namespace XXX {
struct S1 { int i; };
struct S2 { int i; };
bool operator == ( const S1&, const S1& ) { return true; }
template <class T> bool dummy ( const T &x ) { return x==x; }
}
bool operator == ( const XXX::S2&, const XXX::S2& ) { return true; }
void f () { XXX::S2 A; XXX::dummy(A); }
I get the error message
NamespaceBug.cpp: In function `bool XXX::dummy(const T&) [with T = XXX::S2]':
NamespaceBug.cpp:14: instantiated from here
NamespaceBug.cpp:8: no match for `const XXX::S2& == const XXX::S2&' operator
NamespaceBug.cpp:6: candidates are: bool XXX::operator==(const XXX::S1&, const XXX::S1&)
Obviously the compiler fails to find the second operator ==.
Without namespaces or if one leaves out the first operator ==
everything works fine.
(gcc 2.95 shows the same behaviour, so this is not really a
regression. But because gcc 2.95 isn't so picky about the
namespace std, the code worked at least for XXX=std, whereas
gcc 3.0 fails for any namespace name.)
>How-To-Repeat:
g++ -c NamespaceBug.cpp
(assuming the file is named 'NamespaceBug.cpp')
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list