public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24758]  New: Non ambiguous typedefs
@ 2005-11-09 16:59 hhinnant at apple dot com
  2005-11-09 17:03 ` [Bug c++/24758] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: hhinnant at apple dot com @ 2005-11-09 16:59 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/24758] Non ambiguous typedefs
  2005-11-09 16:59 [Bug c++/24758] New: Non ambiguous typedefs hhinnant at apple dot com
@ 2005-11-09 17:03 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-09 17:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-09 17:03 -------
This is a dup of bug 23594.

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


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-09 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-09 16:59 [Bug c++/24758] New: Non ambiguous typedefs hhinnant at apple dot com
2005-11-09 17:03 ` [Bug c++/24758] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).