public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: steev@paradigmds.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/9885: Typedef and namespace problem - scoping silently ignored
Date: Fri, 28 Feb 2003 11:06:00 -0000	[thread overview]
Message-ID: <20030228110307.15823.qmail@sources.redhat.com> (raw)


>Number:         9885
>Category:       c++
>Synopsis:       Typedef and namespace problem - scoping silently ignored
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 28 11:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Steev Wilcox
>Release:        g++ 3.2.1
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
I've reported this because I typed something that g++ didn't interpret in the way I (or anyone else here) expected, and I can't find any information on what really should happen.  Please accept my apologies if you know about this already - I can't find it in your bug list, though.

The following code doesn't do either of the two things that I believe would be sensible:

  namespace a {}
  typedef int a::b;

I can't find in Stroustrup or on the web whether this is legal or not, but I reckon this code should either (i) work, ie define b in namespace a as an int, or (ii) complain that you can't do this, because you need to typedef b inside namespace a.  I think option (ii), hence "accepts-illegal".

What it actually does is silently ignore the "a::" in the typedef (even with -Wall), and typedef b globally to be an int without any warnings or errors, which doesn't seem right.

Contrast this with the case when the typedef is instead a class definition.  In this case, the compiler quite rightly gives an error that you can't define a::b outside of namespace a, but then defines b globally for the rest of the file before stopping.  It might be that the error in the original typedef is being suppressed somehow, but the compiler carries on in the same way.

Sorry again if this isn't actually a bug.  Thanks for looking into it, Steev
>How-To-Repeat:

>Fix:
Put the typedef in the namespace
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-02-28 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-28 11:06 steev [this message]
2003-03-03 15:18 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030228110307.15823.qmail@sources.redhat.com \
    --to=steev@paradigmds.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).