public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation
@ 2010-01-04 13:58 bastien_emmanuel at yahoo dot fr
2010-01-04 14:19 ` [Bug c++/42608] [4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: bastien_emmanuel at yahoo dot fr @ 2010-01-04 13:58 UTC (permalink / raw)
To: gcc-bugs
The following code compiles without error and lead to a seg fault at runtime:
template <class U, class V>
struct A;
template <class V>
struct A<int, V> {
void f();
};
template struct A<int, int>;
int main() {
A<int, int> a;
a.f();
return 0;
}
Notice that there is no body defined for A<int, int>::f(). The correct link
error is reported when no explicit template instantiation is requested:
/tmp/ccycZSyE.o: In function `main':
testcase.cpp:(.text+0x10): undefined reference to `A<int, int>::f()'
collect2: ld returned 1 exit status
$g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.2-7'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--with-arch-32=i486 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.2 (Debian 4.4.2-7)
--
Summary: Undefined reference not reported in case of explicit
template instantiation
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bastien_emmanuel at yahoo dot fr
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
@ 2010-01-04 14:19 ` rguenth at gcc dot gnu dot org
2010-01-05 23:02 ` jason at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-04 14:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2010-01-04 14:19 -------
Confirmed.
Starting with GCC 4.4 we emit:
.size main, .-main
.weak _ZN1AIiiE1fEv
.weak _ZN1AIiiE1fEv
.weak _ZN1AIiiE1fEv
.ident "GCC: (Debian 4.4.2-8) 4.4.2"
.section .note.GNU-stack,"",@progbit
huh.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Known to work| |4.3.4
Last reconfirmed|0000-00-00 00:00:00 |2010-01-04 14:19:25
date| |
Summary|Undefined reference not |[4.4/4.5 Regression]
|reported in case of explicit|Undefined reference not
|template instantiation |reported in case of explicit
| |template instantiation
Target Milestone|--- |4.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
2010-01-04 14:19 ` [Bug c++/42608] [4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
@ 2010-01-05 23:02 ` jason at gcc dot gnu dot org
2010-01-05 23:14 ` jason at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-01-05 23:02 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|2010-01-04 14:19:25 |2010-01-05 23:02:12
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
2010-01-04 14:19 ` [Bug c++/42608] [4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-01-05 23:02 ` jason at gcc dot gnu dot org
@ 2010-01-05 23:14 ` jason at gcc dot gnu dot org
2010-01-07 14:47 ` rguenth at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-01-05 23:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jason at gcc dot gnu dot org 2010-01-05 23:14 -------
This was broken by
2008-08-19 Rafael Espindola <espindola@google.com>
* varasm.c (weak_decls): Move earlier in the file.
(assemble_external): Add weak decls to the weak_decls list.
(declare_weak): Don't add decls to the weak_decls list.
Before this change only declarations explicitly marked weak became weak
references, but after this change any C++ vague linkage function which isn't
defined in the current translation unit becomes a weak reference.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |espindola at gcc dot gnu dot
| |org, jason at gcc dot gnu
| |dot org
AssignedTo|jason at gcc dot gnu dot org|unassigned at gcc dot gnu
| |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (2 preceding siblings ...)
2010-01-05 23:14 ` jason at gcc dot gnu dot org
@ 2010-01-07 14:47 ` rguenth at gcc dot gnu dot org
2010-01-07 19:50 ` jason at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-07 14:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-01-07 14:47 -------
I wonder if the C++ FE should diagnose this as invalid anyway?
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (3 preceding siblings ...)
2010-01-07 14:47 ` rguenth at gcc dot gnu dot org
@ 2010-01-07 19:50 ` jason at gcc dot gnu dot org
2010-01-08 12:06 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-01-07 19:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jason at gcc dot gnu dot org 2010-01-07 19:50 -------
No, there's no way for the front end to know that f isn't instantiated in
another translation unit.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (4 preceding siblings ...)
2010-01-07 19:50 ` jason at gcc dot gnu dot org
@ 2010-01-08 12:06 ` jakub at gcc dot gnu dot org
2010-01-08 13:42 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-01-08 12:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2010-01-08 12:06 -------
Yeah, there are several reasons why DECL_WEAK may be set, but only when it is
because of weak attribute or #pragma weak we want to add it to weak_decls.
For vague linkage, or weakref attribute we don't want to do that.
I wonder whether we couldn't add weak attribute in apply_pragma_weak and just
add to weak_decls decls that have that attribute.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (5 preceding siblings ...)
2010-01-08 12:06 ` jakub at gcc dot gnu dot org
@ 2010-01-08 13:42 ` jakub at gcc dot gnu dot org
2010-01-14 22:41 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-01-08 13:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jakub at gcc dot gnu dot org 2010-01-08 13:42 -------
Created an attachment (id=19507)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19507&action=view)
gcc45-pr42608.patch
Untested fix.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (6 preceding siblings ...)
2010-01-08 13:42 ` jakub at gcc dot gnu dot org
@ 2010-01-14 22:41 ` jakub at gcc dot gnu dot org
2010-01-14 22:47 ` jakub at gcc dot gnu dot org
2010-01-14 23:20 ` jakub at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-01-14 22:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jakub at gcc dot gnu dot org 2010-01-14 22:41 -------
Subject: Bug 42608
Author: jakub
Date: Thu Jan 14 22:41:02 2010
New Revision: 155919
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155919
Log:
PR c++/42608
* varasm.c (declare_weak): Add weak attribute to decl if it
doesn't have one already.
(assemble_external): Only add decls to weak_decls if they also
have weak attribute.
* g++.dg/template/instantiate11.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/template/instantiate11.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/varasm.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (7 preceding siblings ...)
2010-01-14 22:41 ` jakub at gcc dot gnu dot org
@ 2010-01-14 22:47 ` jakub at gcc dot gnu dot org
2010-01-14 23:20 ` jakub at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-01-14 22:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jakub at gcc dot gnu dot org 2010-01-14 22:47 -------
Subject: Bug 42608
Author: jakub
Date: Thu Jan 14 22:46:43 2010
New Revision: 155921
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155921
Log:
PR c++/42608
* varasm.c (declare_weak): Add weak attribute to decl if it
doesn't have one already.
(assemble_external): Only add decls to weak_decls if they also
have weak attribute.
* g++.dg/template/instantiate11.C: New test.
Added:
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/instantiate11.C
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
branches/gcc-4_4-branch/gcc/varasm.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/42608] [4.4/4.5 Regression] Undefined reference not reported in case of explicit template instantiation
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
` (8 preceding siblings ...)
2010-01-14 22:47 ` jakub at gcc dot gnu dot org
@ 2010-01-14 23:20 ` jakub at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-01-14 23:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jakub at gcc dot gnu dot org 2010-01-14 23:20 -------
Fixed.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-01-14 23:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
2010-01-04 14:19 ` [Bug c++/42608] [4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-01-05 23:02 ` jason at gcc dot gnu dot org
2010-01-05 23:14 ` jason at gcc dot gnu dot org
2010-01-07 14:47 ` rguenth at gcc dot gnu dot org
2010-01-07 19:50 ` jason at gcc dot gnu dot org
2010-01-08 12:06 ` jakub at gcc dot gnu dot org
2010-01-08 13:42 ` jakub at gcc dot gnu dot org
2010-01-14 22:41 ` jakub at gcc dot gnu dot org
2010-01-14 22:47 ` jakub at gcc dot gnu dot org
2010-01-14 23:20 ` 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).