This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/24758] New: Non ambiguous typedefs


Here's the test case:
---
typedef unsigned short ushort;

namespace X
{
    typedef unsigned short ushort;
}

using namespace X;

int main()
{
    ushort us = 0;
}
---
prompt> g++ main.cpp

main.cpp: In function 'int main()':
main.cpp:12: error: 'ushort' was not declared in this scope
main.cpp:12: error: expected `;' before 'us'

I'm expecting a clean compile (and it does compile cleanly with CW and Comeau).

The deal is that the typedef ushort is defined in two different places, to the
same type, and then brought "in conflict" via a using declaration.  But since
the two typedefs refer to the same type, I expect that the compiler will see
that there is no conflict, and proceed without error or warning (reference
C++03 7.1.3p2).

Had the two typedefs referred to different types, I expect the compiler to
complain about an ambiguity, for example:

typedef unsigned short ushort;

namespace X
{
    typedef short ushort;
}

using namespace X;

int main()
{
    ushort us = 0;
}

error: ambiguous access to name found 'ushort' and 'X::ushort'

This bug is important as client code commonly includes system headers which
create a lot of common typedefs in the global namespace.  If the user also
(unknowingly) creates the same typedefs, and if there is no conflict, there
should be no error.  If there is a conflict, the error message should be a lot
more helpful than it currently is.


-- 
           Summary: Non ambiguous typedefs
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hhinnant at apple dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]