Bug 220815

Summary: ambiguous references in c++
Product: Red Hat Enterprise Linux 5 Reporter: Oliver Stabel <oliver.stabel>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 5.0CC: aoliva, helge.deller, nphilipp
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-12-29 19:41:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Oliver Stabel 2006-12-27 14:09:05 UTC
Description of problem:
Hi,

it seems this problem is related/similar to an already known one:
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9726>.
Compiling the supplied sample creates an error where the compiler is not able to
properly resolve a symbol.
Note that I am not 100% sure whether this is a bug or an error on my side
(resulting from poor C++ standard knowledge. Comments welcome in this case as well)

Version-Release number of selected component (if applicable):
$ rpm -q gcc
gcc-4.1.1-43.el5
$ uname -a
Linux ls3108v1 2.6.18-1.2747.el5 #1 SMP Thu Nov 9 18:56:16 EST 2006 ia64 ia64
ia64 GNU/Linux

How reproducible:
compile the following with $> c++ -c:
/************/
namespace _STL {

struct __true_type {};
}
using namespace _STL;

struct __true_type { };

namespace std
{
    typedef __true_type __type;
}
/************/

this produces the following output:
test.cpp:11: error: reference to ‘__true_type’ is ambiguous
test.cpp:7: error: candidates are: struct __true_type
test.cpp:3: error:                 struct _STL::__true_type
test.cpp:11: error: reference to ‘__true_type’ is ambiguous
test.cpp:7: error: candidates are: struct __true_type
test.cpp:3: error:                 struct _STL::__true_type
test.cpp:11: error: ‘__true_type’ does not name a type

Steps to Reproduce:
1. c++ -c <sample.cpp>
2.
3.
  
Actual results:

Expected results:


Additional info:

Comment 1 Alexandre Oliva 2006-12-29 19:11:42 UTC
Names brought in by a using directive are found by name lookup as if they were
in the nearest namespace enclosing both the using directive and the nominated
namespace.  Thus, both definitions of __true_type are found in the same
namespace, and ambiguity ensues.