* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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 ` pinskia at gcc dot gnu dot org
2007-03-15 16:07 ` pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-15 16:06 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org, mmitchel at gcc dot gnu
| |dot org
Severity|normal |blocker
GCC build triplet|x86_64-pc-linux-gnu |
GCC host triplet|x86_64-pc-linux-gnu |
Summary|[4.2 regression] extern |[4.2/4.3 regression] extern
|declaration of variable in |declaration of variable in
|anonymous namespace prevents|anonymous namespace prevents
|use of its address as |use of its address as
|template argument |template argument
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-15 16:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-03-15 16:07 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-03-15 16:07:38
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: gdr at cs dot tamu dot edu @ 2007-03-16 15:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gdr at cs dot tamu dot edu 2007-03-16 15:15 -------
Subject: Re: New: [4.2 regression] extern declaration of variable in
anonymous namespace prevents use of its address as template argument
"zak at transversal dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| 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".
Yes, this is a bug in the compiler. I suspect it was introduced when
the the back was told to treat declarations at unnamed namespaces
ast static. That of course is an optimization and should be appear at
the front-end.
-- gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [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 [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
` (2 preceding siblings ...)
2007-03-16 15:15 ` gdr at cs dot tamu dot edu
@ 2007-03-16 15:15 ` Gabriel Dos Reis
2007-03-22 23:17 ` [Bug c++/31187] [4.2/4.3 " mmitchel at gcc dot gnu dot org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Gabriel Dos Reis @ 2007-03-16 15:15 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
"zak at transversal dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| 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".
Yes, this is a bug in the compiler. I suspect it was introduced when
the the back was told to treat declarations at unnamed namespaces
ast static. That of course is an optimization and should be appear at
the front-end.
-- gaby
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (3 preceding siblings ...)
2007-03-16 15:15 ` [Bug c++/31187] New: [4.2 " Gabriel Dos Reis
@ 2007-03-22 23:17 ` mmitchel at gcc dot gnu dot org
2007-03-22 23:34 ` mmitchel at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-03-22 23:17 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (4 preceding siblings ...)
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
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-03-22 23:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from mmitchel at gcc dot gnu dot org 2007-03-22 23:34 -------
Jason --
This appears to be fallout from your patch for PR c++/28407 and/or c++/28409.
Do you have time to take a look?
Thanks,
-- Mark
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (5 preceding siblings ...)
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
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2007-03-23 2:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from bangerth at dealii dot org 2007-03-23 02:37 -------
Without wanting to be a distractor, but can variables of a type that
was declared in an anonymous namespace really have external linkage?
Think of the type being declared in a header file and one .cc file
has the variable declaration/definition and another one an extern
declaration for that variable. Do they refer to the same variable? I
don't think so -- they have the same name, but distinct types, so we
have an ODR violation.
IMHO, variables with a type that comes from an anonymous namespace
can but have internal linkage.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (6 preceding siblings ...)
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
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mark at codesourcery dot com @ 2007-03-23 2:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from mark at codesourcery dot com 2007-03-23 02:44 -------
Subject: Re: [4.2/4.3 regression] extern declaration of variable
in anonymous namespace prevents use of its address as template argument
bangerth at dealii dot org wrote:
> ------- Comment #4 from bangerth at dealii dot org 2007-03-23 02:37 -------
> Without wanting to be a distractor, but can variables of a type that
> was declared in an anonymous namespace really have external linkage?
That's not the case here; the class is in the global namespace. Only
the variable is in the anonymous namespace, and entities in anonymous
namespaces do have external linkage.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (7 preceding siblings ...)
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
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2007-03-23 3:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from bangerth at dealii dot org 2007-03-23 03:03 -------
(In reply to comment #5)
> That's not the case here; the class is in the global namespace.
Oh, bummer, of course...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (8 preceding siblings ...)
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
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-03-27 2:37 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-03-15 16:07:38 |2007-03-27 03:37:29
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (9 preceding siblings ...)
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
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-04-02 17:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jason at gcc dot gnu dot org 2007-04-02 18:49 -------
Subject: Bug 31187
Author: jason
Date: Mon Apr 2 18:49:21 2007
New Revision: 123432
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123432
Log:
PR c++/31187
* typeck.c (cp_type_readonly): New fn.
* cp-tree.h: Declare it.
* decl.c (start_decl): Set implicit DECL_THIS_STATIC here.
(cp_finish_decl): Not here.
* g++.dg/ext/visibility/anon3.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/ext/visibility/anon3.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/decl.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (10 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-04-02 19:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jason at gcc dot gnu dot org 2007-04-02 20:12 -------
Subject: Bug 31187
Author: jason
Date: Mon Apr 2 20:12:15 2007
New Revision: 123434
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123434
Log:
PR c++/31187
* typeck.c (cp_type_readonly): New fn.
* cp-tree.h: Declare it.
* decl.c (start_decl): Set implicit DECL_THIS_STATIC here.
(cp_finish_decl): Not here.
* g++.dg/ext/visibility/anon3.C: New test.
Added:
branches/gcc-4_2-branch/gcc/testsuite/g++.dg/ext/visibility/anon3.C
- copied unchanged from r123432,
trunk/gcc/testsuite/g++.dg/ext/visibility/anon3.C
Modified:
branches/gcc-4_2-branch/gcc/cp/ChangeLog
branches/gcc-4_2-branch/gcc/cp/cp-tree.h
branches/gcc-4_2-branch/gcc/cp/decl.c
branches/gcc-4_2-branch/gcc/cp/typeck.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (11 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-04-09 21:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jason at gcc dot gnu dot org 2007-04-09 22:43 -------
Fixed in 4.2 branch and trunk.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/31187] [4.2/4.3 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
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
` (12 preceding siblings ...)
2007-04-09 21:43 ` jason at gcc dot gnu dot org
@ 2007-06-26 11:58 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-06-26 11:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jakub at gcc dot gnu dot org 2007-06-26 11:57 -------
Subject: Bug 31187
Author: jakub
Date: Tue Jun 26 11:57:42 2007
New Revision: 126027
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126027
Log:
2007-03-30 Jason Merrill <jason@redhat.com>
PR c++/31187
* typeck.c (cp_type_readonly): New fn.
* cp-tree.h: Declare it.
* decl.c (start_decl): Set implicit DECL_THIS_STATIC here.
(cp_finish_decl): Not here.
2007-04-02 Jason Merrill <jason@redhat.com>
PR c++/31187
* g++.dg/ext/visibility/anon3.C: New test.
Added:
branches/redhat/gcc-4_1-branch/gcc/testsuite/g++.dg/ext/visibility/anon3.C
Modified:
branches/redhat/gcc-4_1-branch/gcc/cp/ChangeLog
branches/redhat/gcc-4_1-branch/gcc/cp/cp-tree.h
branches/redhat/gcc-4_1-branch/gcc/cp/decl.c
branches/redhat/gcc-4_1-branch/gcc/cp/typeck.c
branches/redhat/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187
^ permalink raw reply [flat|nested] 15+ messages in thread