public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration
@ 2021-02-10 18:32 redi at gcc dot gnu.org
2021-02-10 18:39 ` [Bug c++/99066] " jakub at gcc dot gnu.org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-10 18:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Bug ID: 99066
Summary: non-weak definition emitted for explicit instantiation
declaration
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: link-failure
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
If two TUs both include a header that contains:
template <typename a> struct basic_string {
static const int npos = 1;
};
template <typename a> const int basic_string<a>::npos;
struct e { template <bool> int f() const; };
template <bool> int e::f() const {
return basic_string<char>::npos;
}
extern template class basic_string<char>;
then we get a linker error, because both TUs define the npos constant:
/usr/bin/ld: /tmp/ccjy3Spq.o:(.rodata+0x0): multiple definition of
`basic_string<char>::npos'; /tmp/ccMQ33nr.o:(.rodata+0x0): first defined here
Shouldn't the static data member only have weak definitions, unless an explicit
instantiation definition is seen?
/* TU 1 */
#include "str.h"
int main()
{
return e().f<true>();
}
/* TU 2 */
#include "str.h"
The assembly for both files contains:
.globl _ZN12basic_stringIcE4nposE
.section .rodata
.align 4
.type _ZN12basic_stringIcE4nposE, @object
.size _ZN12basic_stringIcE4nposE, 4
_ZN12basic_stringIcE4nposE:
.long 1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
@ 2021-02-10 18:39 ` jakub at gcc dot gnu.org
2021-02-10 18:44 ` [Bug c++/99066] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-10 18:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org,
| |mpolacek at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, r104000 still doesn't emit it but r104500 already does, so perhaps a 4.1
GCC era regression?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10/11 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
2021-02-10 18:39 ` [Bug c++/99066] " jakub at gcc dot gnu.org
@ 2021-02-10 18:44 ` jakub at gcc dot gnu.org
2021-02-10 18:55 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-10 18:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
Summary|non-weak definition emitted |[8/9/10/11 Regression]
|for explicit instantiation |non-weak definition emitted
|declaration |for explicit instantiation
| |declaration
Target Milestone|--- |8.5
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10/11 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
2021-02-10 18:39 ` [Bug c++/99066] " jakub at gcc dot gnu.org
2021-02-10 18:44 ` [Bug c++/99066] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
@ 2021-02-10 18:55 ` jakub at gcc dot gnu.org
2021-04-04 15:59 ` jason at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-10 18:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-02-10
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps caused by PR23691 changes?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10/11 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (2 preceding siblings ...)
2021-02-10 18:55 ` jakub at gcc dot gnu.org
@ 2021-04-04 15:59 ` jason at gcc dot gnu.org
2021-04-05 13:26 ` jason at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-04 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10/11 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (3 preceding siblings ...)
2021-04-04 15:59 ` jason at gcc dot gnu.org
@ 2021-04-05 13:26 ` jason at gcc dot gnu.org
2021-04-05 13:29 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-05 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Perhaps caused by PR23691 changes?
r104041, yes. Bizarre that this went unnoticed for over 15 years.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10/11 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (4 preceding siblings ...)
2021-04-05 13:26 ` jason at gcc dot gnu.org
@ 2021-04-05 13:29 ` cvs-commit at gcc dot gnu.org
2021-04-05 13:30 ` [Bug c++/99066] [8/9/10 " jason at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-05 13:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:bd89b8fe9efbdf0a95d827553d1a84fd3cefaa16
commit r11-7986-gbd89b8fe9efbdf0a95d827553d1a84fd3cefaa16
Author: Jason Merrill <jason@redhat.com>
Date: Sun Apr 4 23:32:32 2021 -0400
c++: extern template and static data member [PR99066]
'extern template' should mean that the relevant symbols are never emitted.
But in this case we were assuming that DECL_EXTERNAL was already set on the
variable, so we just needed to clear DECL_NOT_REALLY_EXTERN. Since
DECL_EXTERNAL was not set, we emitted a definition of npos.
gcc/cp/ChangeLog:
PR c++/99066
* pt.c (mark_decl_instantiated): Set DECL_EXTERNAL.
gcc/testsuite/ChangeLog:
PR c++/99066
* g++.dg/cpp0x/extern_template-6.C: New test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (5 preceding siblings ...)
2021-04-05 13:29 ` cvs-commit at gcc dot gnu.org
@ 2021-04-05 13:30 ` jason at gcc dot gnu.org
2021-04-05 18:58 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-05 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[8/9/10/11 Regression] |[8/9/10 Regression]
|non-weak definition emitted |non-weak definition emitted
|for explicit instantiation |for explicit instantiation
|declaration |declaration
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11 so far.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [8/9/10 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (6 preceding siblings ...)
2021-04-05 13:30 ` [Bug c++/99066] [8/9/10 " jason at gcc dot gnu.org
@ 2021-04-05 18:58 ` redi at gcc dot gnu.org
2021-05-14 9:54 ` [Bug c++/99066] [9/10 " jakub at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-05 18:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #3)
> r104041, yes. Bizarre that this went unnoticed for over 15 years.
Very surprising, isn't it!
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [9/10 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (7 preceding siblings ...)
2021-04-05 18:58 ` redi at gcc dot gnu.org
@ 2021-05-14 9:54 ` jakub at gcc dot gnu.org
2021-06-01 8:19 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14 9:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|8.5 |9.4
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [9/10 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (8 preceding siblings ...)
2021-05-14 9:54 ` [Bug c++/99066] [9/10 " jakub at gcc dot gnu.org
@ 2021-06-01 8:19 ` rguenth at gcc dot gnu.org
2022-05-13 17:14 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01 8:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.4 |9.5
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [9/10 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (9 preceding siblings ...)
2021-06-01 8:19 ` rguenth at gcc dot gnu.org
@ 2022-05-13 17:14 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` [Bug c++/99066] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 18:26 ` jason at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 17:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:20b503f1125c0b0a7f4b2bb1214d4a3cc6fd9f70
commit r10-10735-g20b503f1125c0b0a7f4b2bb1214d4a3cc6fd9f70
Author: Jason Merrill <jason@redhat.com>
Date: Sun Apr 4 23:32:32 2021 -0400
c++: extern template and static data member [PR99066]
'extern template' should mean that the relevant symbols are never emitted.
But in this case we were assuming that DECL_EXTERNAL was already set on the
variable, so we just needed to clear DECL_NOT_REALLY_EXTERN. Since
DECL_EXTERNAL was not set, we emitted a definition of npos.
gcc/cp/ChangeLog:
PR c++/99066
* pt.c (mark_decl_instantiated): Set DECL_EXTERNAL.
gcc/testsuite/ChangeLog:
PR c++/99066
* g++.dg/cpp0x/extern_template-6.C: New test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [9 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (10 preceding siblings ...)
2022-05-13 17:14 ` cvs-commit at gcc dot gnu.org
@ 2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:26 ` jason at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 18:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:950a97a5039c7b96602edfdf8984b5800f5837f3
commit r9-10179-g950a97a5039c7b96602edfdf8984b5800f5837f3
Author: Jason Merrill <jason@redhat.com>
Date: Sun Apr 4 23:32:32 2021 -0400
c++: extern template and static data member [PR99066]
'extern template' should mean that the relevant symbols are never emitted.
But in this case we were assuming that DECL_EXTERNAL was already set on the
variable, so we just needed to clear DECL_NOT_REALLY_EXTERN. Since
DECL_EXTERNAL was not set, we emitted a definition of npos.
gcc/cp/ChangeLog:
PR c++/99066
* pt.c (mark_decl_instantiated): Set DECL_EXTERNAL.
gcc/testsuite/ChangeLog:
PR c++/99066
* g++.dg/cpp0x/extern_template-6.C: New test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/99066] [9 Regression] non-weak definition emitted for explicit instantiation declaration
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
` (11 preceding siblings ...)
2022-05-13 18:24 ` [Bug c++/99066] [9 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 18:26 ` jason at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99066
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-05-13 18:26 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 18:32 [Bug c++/99066] New: non-weak definition emitted for explicit instantiation declaration redi at gcc dot gnu.org
2021-02-10 18:39 ` [Bug c++/99066] " jakub at gcc dot gnu.org
2021-02-10 18:44 ` [Bug c++/99066] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
2021-02-10 18:55 ` jakub at gcc dot gnu.org
2021-04-04 15:59 ` jason at gcc dot gnu.org
2021-04-05 13:26 ` jason at gcc dot gnu.org
2021-04-05 13:29 ` cvs-commit at gcc dot gnu.org
2021-04-05 13:30 ` [Bug c++/99066] [8/9/10 " jason at gcc dot gnu.org
2021-04-05 18:58 ` redi at gcc dot gnu.org
2021-05-14 9:54 ` [Bug c++/99066] [9/10 " jakub at gcc dot gnu.org
2021-06-01 8:19 ` rguenth at gcc dot gnu.org
2022-05-13 17:14 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` [Bug c++/99066] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 18:26 ` jason at gcc dot gnu.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).