public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zak at transversal dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/31187]  New: [4.2 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
Date: Thu, 15 Mar 2007 14:25:00 -0000	[thread overview]
Message-ID: <bug-31187-1827@http.gcc.gnu.org/bugzilla/> (raw)

The following code, which compiles fine on gcc 4.1.2 and I believe is valid,
fails on an up-to-date checkout from the 4.2 branch:

--------------------------------------
class foo { };

namespace
{
        extern foo foo1;
        foo foo1;
}

template< foo * >
class bar { };

bar< &foo1 > bar1;
---------------------------------------

giving the error:

test.cc:12: error: '&<unnamed>::foo1' is not a valid template argument of type
'foo*' because '<unnamed>::foo1' does not have external linkage
test.cc:12: error: invalid type in declaration before ';' token


... which I would only expect if "foo1" were declared "static".


If I remove the line with the "extern" declaration, the code compiles again on
4.2.


-- 
           Summary: [4.2 regression] extern declaration of variable in
                    anonymous namespace prevents use of its address as
                    template argument
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zak at transversal dot com
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


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


             reply	other threads:[~2007-03-15 14:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-15 14:25 zak at transversal dot com [this message]
2007-03-15 16:06 ` [Bug c++/31187] [4.2/4.3 " pinskia at gcc dot gnu dot org
2007-03-15 16:07 ` pinskia at gcc dot gnu dot org
2007-03-16 15:15 ` gdr at cs dot tamu dot edu
2007-03-16 15:15 ` [Bug c++/31187] New: [4.2 " Gabriel Dos Reis
2007-03-22 23:17 ` [Bug c++/31187] [4.2/4.3 " mmitchel at gcc dot gnu dot org
2007-03-22 23:34 ` mmitchel at gcc dot gnu dot org
2007-03-23  2:37 ` bangerth at dealii dot org
2007-03-23  2:44 ` mark at codesourcery dot com
2007-03-23  3:03 ` bangerth at dealii dot org
2007-03-27  2:37 ` jason at gcc dot gnu dot org
2007-04-02 17:50 ` jason at gcc dot gnu dot org
2007-04-02 19:12 ` jason at gcc dot gnu dot org
2007-04-09 21:43 ` jason at gcc dot gnu dot org
2007-06-26 11:58 ` jakub at gcc dot gnu dot org

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=bug-31187-1827@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).