public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15664] New: Linker fails to find (inline) function
@ 2004-05-27 11:39 igodard at pacbell dot net
2004-05-27 11:41 ` [Bug c++/15664] " igodard at pacbell dot net
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 11:39 UTC (permalink / raw)
To: gcc-bugs
Linker doesn't find operator==(class, class). The definition of the operator is "inline", but removing that doesn't help. Problem occurs in both -O0 and -O2, consistent with inline not important. Operator is declared, then redeclared as a friend, then defined. The definition finds the friend (comment out friend gives syntax errors on invisibles in the definition). The first declaration is not needed; no change if it is commented out. I suspect an error in name mangling, as the operator has a complicated type with two template templates, but the type listed in the error message seems correct.
--
Summary: Linker fails to find (inline) function
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
@ 2004-05-27 11:41 ` igodard at pacbell dot net
2004-05-27 11:44 ` igodard at pacbell dot net
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 11:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-05-26 18:56 -------
Created an attachment (id=6386)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6386&action=view)
Compiler output (-v -save-temps)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
2004-05-27 11:41 ` [Bug c++/15664] " igodard at pacbell dot net
@ 2004-05-27 11:44 ` igodard at pacbell dot net
2004-05-27 11:44 ` igodard at pacbell dot net
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 11:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-05-26 19:07 -------
More info: if the friend declaration is removed (with everything necessary made public so the definition compiles) then the problem goes away. This suggests that the compiler is generating a reference to the friend somehow, and not considering the definition to be the same as the friend. Odd.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
2004-05-27 11:41 ` [Bug c++/15664] " igodard at pacbell dot net
2004-05-27 11:44 ` igodard at pacbell dot net
@ 2004-05-27 11:44 ` igodard at pacbell dot net
2004-05-27 11:47 ` bangerth at dealii dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 11:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-05-26 18:57 -------
Created an attachment (id=6387)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6387&action=view)
Source code (-save-temps)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (2 preceding siblings ...)
2004-05-27 11:44 ` igodard at pacbell dot net
@ 2004-05-27 11:47 ` bangerth at dealii dot org
2004-05-27 12:12 ` igodard at pacbell dot net
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2004-05-27 11:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-05-26 19:21 -------
Your code looks like this:
-------------------
template<typename E, template<typename>class A1, template<typename>class A2>
bool operator==(const Powerbase<E, A1>& p1, const Powerbase<E, A2>& p2);
template<typename E, template<typename> class Alloc>
class Powerbase
{
template<template<typename>class A2>
friend
bool operator==(const Powerbase<E, Alloc>& p1,
const Powerbase<E, A2>& p2);
};
template<typename E, template<typename> class A1, template<typename>class A2>
inline
bool operator==(const Powerbase<E, A1>& p1,
const Powerbase<E, A2>& p2) {
return p1.Relop(p2, Powerbase<E, A1>::equalOp);
}
-------------------------
The problem with it is that the friend declaration is not for the function
you have previously declared (easily seen by the fact that it has only one
instead of three template arguments). Thus, the compiler assumes that it
is a previously undeclared overload of operator== and injects it into the
global namespace. You therefore have two overloaded declarations, and the
compiler later on in the program happens to pick the one that was
declared in the friend declaration. It doesn't exist, though, thus the
linker error.
The general rule is: since there are no partial specializations for template
functions, the only thing you can declare a friend is a general template,
in this case the three-argument template. You can't declare only certain
possible instantiations of a template a friend.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (3 preceding siblings ...)
2004-05-27 11:47 ` bangerth at dealii dot org
@ 2004-05-27 12:12 ` igodard at pacbell dot net
2004-05-27 13:05 ` igodard at pacbell dot net
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 12:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-05-26 19:54 -------
Thanks for the explanation - they do help. Unfortunately I had already used the three-argument form and gotten compile errors. With experimentation I found that the one-argument form at least compiled though it wouldn't link. Herewith are the 3-argument results.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (4 preceding siblings ...)
2004-05-27 12:12 ` igodard at pacbell dot net
@ 2004-05-27 13:05 ` igodard at pacbell dot net
2004-05-27 13:17 ` igodard at pacbell dot net
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 13:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-05-26 19:55 -------
Created an attachment (id=6388)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6388&action=view)
Compiler output (-v -save-temps) - 3 args
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (5 preceding siblings ...)
2004-05-27 13:05 ` igodard at pacbell dot net
@ 2004-05-27 13:17 ` igodard at pacbell dot net
2004-05-27 13:50 ` bangerth at dealii dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: igodard at pacbell dot net @ 2004-05-27 13:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-05-26 19:56 -------
Created an attachment (id=6389)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6389&action=view)
Source code (-save-temps) - 3 args
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Linker fails to find (inline) function
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (6 preceding siblings ...)
2004-05-27 13:17 ` igodard at pacbell dot net
@ 2004-05-27 13:50 ` bangerth at dealii dot org
2004-05-27 18:48 ` [Bug c++/15664] Template friend injection fails giovannibajo at libero dot it
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2004-05-27 13:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-05-26 20:56 -------
Alright, that's better. I think this actually shows a gcc bug:
------------------
template <int N> struct S {
template<template<typename> class A>
friend void foo();
};
template<template<typename> class A>
void foo();
template <typename> struct X {};
int main () {
S<1> s;
foo<X>();
}
-------------------
The friend declaration should inject the name into the global namespace,
and it should be identified with the other declaration. However, we get
this:
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc
x.cc: In function `int main()':
x.cc:13: error: call of overloaded `foo()' is ambiguous
x.cc:7: error: candidates are: void foo() [with A = X]
x.cc:3: error: void foo() [with A = X, int N = 1]
(Note also that the last line is pretty bad, since it lists the
template argument to the enclosing class, which, however, isn't
specified at all in the rest of the line.) Interestingly enough,
the error goes away if
a) S is made a non-template
b) foo takes as template argument not a template template parameter,
but a regular type or value
May someone else try to figure out from this what's going wrong.
This bug is on all versions of gcc.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |2.95.3 3.3.4 3.4.0
Last reconfirmed|0000-00-00 00:00:00 |2004-05-26 20:56:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Template friend injection fails
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (7 preceding siblings ...)
2004-05-27 13:50 ` bangerth at dealii dot org
@ 2004-05-27 18:48 ` giovannibajo at libero dot it
2004-08-12 0:57 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: giovannibajo at libero dot it @ 2004-05-27 18:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-05-27 08:36 -------
Confirmed, and this is the Nth bug of ours about friend name injection...
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Summary|Linker fails to find |Template friend injection
|(inline) function |fails
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Template friend injection fails
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (8 preceding siblings ...)
2004-05-27 18:48 ` [Bug c++/15664] Template friend injection fails giovannibajo at libero dot it
@ 2004-08-12 0:57 ` pinskia at gcc dot gnu dot org
2004-11-11 12:44 ` lerdsuwa at gcc dot gnu dot org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-12 0:57 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |16995
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Template friend injection fails
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (9 preceding siblings ...)
2004-08-12 0:57 ` pinskia at gcc dot gnu dot org
@ 2004-11-11 12:44 ` lerdsuwa at gcc dot gnu dot org
2004-11-12 16:58 ` lerdsuwa at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-11-11 12:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-11-11 12:44 -------
A template template parameter bug, probably a duplicate of PR18276.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |lerdsuwa at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Template friend injection fails
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (10 preceding siblings ...)
2004-11-11 12:44 ` lerdsuwa at gcc dot gnu dot org
@ 2004-11-12 16:58 ` lerdsuwa at gcc dot gnu dot org
2004-12-02 12:01 ` cvs-commit at gcc dot gnu dot org
2004-12-02 12:02 ` lerdsuwa at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-11-12 16:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-11-12 16:58 -------
Patch submitted:
http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00971.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Template friend injection fails
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (11 preceding siblings ...)
2004-11-12 16:58 ` lerdsuwa at gcc dot gnu dot org
@ 2004-12-02 12:01 ` cvs-commit at gcc dot gnu dot org
2004-12-02 12:02 ` lerdsuwa at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-02 12:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-12-02 12:00 -------
Subject: Bug 15664
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: lerdsuwa@gcc.gnu.org 2004-12-02 12:00:44
Modified files:
gcc/cp : ChangeLog pt.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/template: ttp13.C ttp14.C
Log message:
PR c++/15664, c++/18276
* pt.c (tsubst_decl) <TEMPLATE_DECL case>: Reorganize. Correctly
tsubst TEMPLATE_DECL that is a TEMPLATE_TEMPLATE_PARM.
* g++.dg/template/ttp13.C: New test.
* g++.dg/template/ttp14.C: Likewise.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4510&r2=1.4511
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.952&r2=1.953
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4706&r2=1.4707
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ttp13.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ttp14.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/15664] Template friend injection fails
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
` (12 preceding siblings ...)
2004-12-02 12:01 ` cvs-commit at gcc dot gnu dot org
@ 2004-12-02 12:02 ` lerdsuwa at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-12-02 12:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-12-02 12:02 -------
Fixed in the mainline.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15664
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2004-12-02 12:02 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-27 11:39 [Bug c++/15664] New: Linker fails to find (inline) function igodard at pacbell dot net
2004-05-27 11:41 ` [Bug c++/15664] " igodard at pacbell dot net
2004-05-27 11:44 ` igodard at pacbell dot net
2004-05-27 11:44 ` igodard at pacbell dot net
2004-05-27 11:47 ` bangerth at dealii dot org
2004-05-27 12:12 ` igodard at pacbell dot net
2004-05-27 13:05 ` igodard at pacbell dot net
2004-05-27 13:17 ` igodard at pacbell dot net
2004-05-27 13:50 ` bangerth at dealii dot org
2004-05-27 18:48 ` [Bug c++/15664] Template friend injection fails giovannibajo at libero dot it
2004-08-12 0:57 ` pinskia at gcc dot gnu dot org
2004-11-11 12:44 ` lerdsuwa at gcc dot gnu dot org
2004-11-12 16:58 ` lerdsuwa at gcc dot gnu dot org
2004-12-02 12:01 ` cvs-commit at gcc dot gnu dot org
2004-12-02 12:02 ` lerdsuwa 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).