public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31187]  New: [4.2 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
@ 2007-03-15 14:25 zak at transversal dot com
  2007-03-15 16:06 ` [Bug c++/31187] [4.2/4.3 " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: zak at transversal dot com @ 2007-03-15 14:25 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2007-06-26 11:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-15 14:25 [Bug c++/31187] New: [4.2 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument zak at transversal dot com
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

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).