Bug 24758 - Non ambiguous typedefs
Summary: Non ambiguous typedefs
Status: RESOLVED DUPLICATE of bug 23594
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-09 16:59 UTC by Howard Hinnant
Modified: 2005-11-09 17:03 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Howard Hinnant 2005-11-09 16:59:39 UTC
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.
Comment 1 Andrew Pinski 2005-11-09 17:03:25 UTC
This is a dup of bug 23594.

*** This bug has been marked as a duplicate of 23594 ***