public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later
@ 2005-06-30 23:18 sebor at roguewave dot com
  2005-06-30 23:26 ` [Bug c++/22263] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: sebor at roguewave dot com @ 2005-06-30 23:18 UTC (permalink / raw)
  To: gcc-bugs

The program below fails to link with g++ 4.0 on Solaris 9 (I didn't try Linux).
It appears that symbols defined after the explicit instantiation directive
aren't emitted even when referenced. This works fine with prior versions of gcc.

$ cat u.cpp && g++ u.cpp
template <class T> struct S { T foo (); T bar (); };
template <class T> T S<T>::foo () { return bar (); }
template struct S<int>;
template <class T> T S<T>::bar () { return T (); }

int main () { return S<int>().foo (); }
Undefined                       first referenced
 symbol                             in file
S<int>::bar()                       /var/tmp//cc4BNMlG.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

-- 
           Summary: explicit instantiation fails to emit symbols defined
                    later
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.9
  GCC host triplet: sparc-sun-solaris2.9
GCC target triplet: sparc-sun-solaris2.9


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


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

* [Bug c++/22263] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
@ 2005-06-30 23:26 ` pinskia at gcc dot gnu dot org
  2005-06-30 23:36 ` sebor at roguewave dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30 23:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-30 23:26 -------
Explicit instantiation should not instantitate the symbols defined later after the explicit instatntiation 
see PR 21118, but this is a weird problem as we now have a symbol defined afterwards which is used 
by the already instantiatied template.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|sparc-sun-solaris2.9        |
   GCC host triplet|sparc-sun-solaris2.9        |
 GCC target triplet|sparc-sun-solaris2.9        |


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


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

* [Bug c++/22263] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
  2005-06-30 23:26 ` [Bug c++/22263] " pinskia at gcc dot gnu dot org
@ 2005-06-30 23:36 ` sebor at roguewave dot com
  2005-06-30 23:49 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sebor at roguewave dot com @ 2005-06-30 23:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sebor at roguewave dot com  2005-06-30 23:36 -------
Sorry about the duplicate PR. I searched Bugzilla for an existing report but
obviously not thoroughly enough.

I'm afraid I disagree with the analysis in both PRs. From 14.7.2, p7:

  The explicit instantiation of a class template specialization implies
  the instantiation of all of its members not previously explicitly
  specialized in the translation unit containing the explicit
  instantiation.


-- 


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


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

* [Bug c++/22263] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
  2005-06-30 23:26 ` [Bug c++/22263] " pinskia at gcc dot gnu dot org
  2005-06-30 23:36 ` sebor at roguewave dot com
@ 2005-06-30 23:49 ` pinskia at gcc dot gnu dot org
  2005-06-30 23:57 ` sebor at roguewave dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30 23:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-30 23:49 -------
(In reply to comment #2)
> Sorry about the duplicate PR. I searched Bugzilla for an existing report but
> obviously not thoroughly enough.
> 
> I'm afraid I disagree with the analysis in both PRs. From 14.7.2, p7:

That P only applies to specializations if I read it correctly and there is no specialization in your testcase.

-- 


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


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

* [Bug c++/22263] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (2 preceding siblings ...)
  2005-06-30 23:49 ` pinskia at gcc dot gnu dot org
@ 2005-06-30 23:57 ` sebor at roguewave dot com
  2005-07-01  0:06 ` sebor at roguewave dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sebor at roguewave dot com @ 2005-06-30 23:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sebor at roguewave dot com  2005-06-30 23:56 -------
I don't believe you are reading the paragraph correctly.

The paragraph applies to explicit instantiation. The reference to explicit
specialization allows members of the class template that is being explicitly
instantiated to be explicitly specialized prior to the explicit instantiation.

This allowance is necessary since the opposite (i.e., specializing the member
after the containing class template has been instantiated, explicitly or
otherwise) is not permitted.

-- 


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


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

* [Bug c++/22263] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (3 preceding siblings ...)
  2005-06-30 23:57 ` sebor at roguewave dot com
@ 2005-07-01  0:06 ` sebor at roguewave dot com
  2005-07-01 19:07 ` [Bug c++/22263] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sebor at roguewave dot com @ 2005-07-01  0:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sebor at roguewave dot com  2005-07-01 00:06 -------
Further, in response to comment 2 from bug 22263:

I agree that 14.7.2, p3 applies to that case but since the definition of class b
is in scope at the point of the explicit instantiation of the class template I
believe the test case is well-formed. The definition of a class template doesn't
necessarily imply the definition of all its members, just their declaration.

I don't see any practical difference between either of these cases and the case
of explicitly instantiating a non-member function template which need only be
declared but not necessarily defined at the point of the explicit instantiation.

As an additional data point, the behavior implemented by all other compilers is
to instantiate all members regardless of whether they are defined prior or after
the directive.

-- 


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (4 preceding siblings ...)
  2005-07-01  0:06 ` sebor at roguewave dot com
@ 2005-07-01 19:07 ` pinskia at gcc dot gnu dot org
  2005-07-06 16:39 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-01 19:07 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org
           Keywords|                            |wrong-code
            Summary|explicit instantiation fails|[4.0/4.1 Regression]
                   |to emit symbols defined     |explicit instantiation fails
                   |later                       |to emit symbols defined
                   |                            |later
   Target Milestone|---                         |4.0.1


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (5 preceding siblings ...)
  2005-07-01 19:07 ` [Bug c++/22263] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-07-06 16:39 ` mmitchel at gcc dot gnu dot org
  2005-07-17 23:10 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-07-06 16:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-07-06 16:38 -------
This is rejects-valid, not wrong-code, because the failure mode is that the
program doesn't link.  (Unless you violate the ODR.)

Postponed until 4.0.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |rejects-valid
   Target Milestone|4.0.1                       |4.0.2


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (6 preceding siblings ...)
  2005-07-06 16:39 ` mmitchel at gcc dot gnu dot org
@ 2005-07-17 23:10 ` mmitchel at gcc dot gnu dot org
  2005-07-18 15:57 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-07-17 23:10 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (7 preceding siblings ...)
  2005-07-17 23:10 ` mmitchel at gcc dot gnu dot org
@ 2005-07-18 15:57 ` cvs-commit at gcc dot gnu dot org
  2005-07-18 17:15 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-18 15:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-18 15:44 -------
Subject: Bug 22263

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2005-07-18 15:44:36

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog cp-tree.h decl2.c pt.c 
Added files:
	gcc/testsuite/g++.dg/template: explicit7.C 

Log message:
	PR c++/22263
	* cp-tree.h (instantiate_decl): Change prototype.
	* decl2.c (mark_used): Adjust accordingly.
	* pt.c (do_decl_instantiation): Likewise.
	(instantiate_class_member): Likewise.
	(instantiate_decl): Rename undefined_ok as expl_inst_class_mem_p.
	Clear DECL_INTERFACE_KNOWN for an explicitly instantiated template
	that has no definition available.
	(instantiate_pending_templates): Adjust call to instantiate_decl.
	
	PR c++/22263
	* g++.dg/template/explicit7.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5779&r2=1.5780
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/explicit7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4824&r2=1.4825
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1155&r2=1.1156
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.791&r2=1.792
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1015&r2=1.1016



-- 


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (8 preceding siblings ...)
  2005-07-18 15:57 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-18 17:15 ` cvs-commit at gcc dot gnu dot org
  2005-07-18 17:24 ` mmitchel at gcc dot gnu dot org
  2005-10-01 17:07 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-18 17:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-18 17:08 -------
Subject: Bug 22263

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	mmitchel@gcc.gnu.org	2005-07-18 17:08:22

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: explicit7.C 

Log message:
	PR c++/22263
	* g++.dg/template/explicit7.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.69&r2=1.4648.2.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.13&r2=1.978.2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.285&r2=1.5084.2.286
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/explicit7.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (9 preceding siblings ...)
  2005-07-18 17:15 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-18 17:24 ` mmitchel at gcc dot gnu dot org
  2005-10-01 17:07 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-07-18 17:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-07-18 17:22 -------
Fixed in 4.0.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug c++/22263] [4.0/4.1 Regression] explicit instantiation fails to emit symbols defined later
  2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
                   ` (10 preceding siblings ...)
  2005-07-18 17:24 ` mmitchel at gcc dot gnu dot org
@ 2005-10-01 17:07 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-01 17:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-10-01 17:07 -------
*** Bug 24164 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rogers at anthro dot utah
                   |                            |dot edu


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


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

end of thread, other threads:[~2005-10-01 17:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-30 23:18 [Bug c++/22263] New: explicit instantiation fails to emit symbols defined later sebor at roguewave dot com
2005-06-30 23:26 ` [Bug c++/22263] " pinskia at gcc dot gnu dot org
2005-06-30 23:36 ` sebor at roguewave dot com
2005-06-30 23:49 ` pinskia at gcc dot gnu dot org
2005-06-30 23:57 ` sebor at roguewave dot com
2005-07-01  0:06 ` sebor at roguewave dot com
2005-07-01 19:07 ` [Bug c++/22263] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-07-06 16:39 ` mmitchel at gcc dot gnu dot org
2005-07-17 23:10 ` mmitchel at gcc dot gnu dot org
2005-07-18 15:57 ` cvs-commit at gcc dot gnu dot org
2005-07-18 17:15 ` cvs-commit at gcc dot gnu dot org
2005-07-18 17:24 ` mmitchel at gcc dot gnu dot org
2005-10-01 17:07 ` pinskia 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).