public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5962: g++ compile an link
@ 2002-03-14 4:36 onofre
0 siblings, 0 replies; 2+ messages in thread
From: onofre @ 2002-03-14 4:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 5962
>Category: c++
>Synopsis: g++ compile an link
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 14 04:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: onofre@ieav.cta.br
>Release: gcc version 3.0.4
>Organization:
>Environment:
conectiva linux
2.2.17-14cl #1 qui nov 2 00:24:54 EST 2000 i686
and mandrake 8.1 2.4.8
>Description:
when I try to compile the code that use template and friend
function the link show-me a message
g++ -o tcomplex tComplex.cc
tComplex.cc:15: warning: friend declaration `bool operator==(const Complex<T>&,
const Complex<T>&)' declares a non-template function
tComplex.cc:15: warning: (if this is not what you intended, make sure the
function template has already been declared and add <> after the function
name here) -Wno-non-template-friend disables this warning.
IMPORTANTE PARTE
/tmp/ccxZWYam.o: In function `main':
/tmp/ccxZWYam.o(.text+0x4d): undefined reference to `operator==(Complex<float> const&, Complex<float> const&)'
collect2: ld returned 1 exit status
>How-To-Repeat:
#include <iostream.h>
template <class T>
class Complex
{
public:
T a,b;
Complex(T ,T);
T Real();
T Imag();
friend bool operator==(const Complex <T> &,const Complex<T> &);
};
template <class T>
Complex<T>::Complex(T x,T y)
{
a = x;
b = y;
}
template <class T>
T Complex<T>::Real()
{
return a;
}
template <class T>
T Complex<T>::Imag()
{
return b;
}
template <class T>
bool operator ==(const Complex<T> &Ca,const Complex<T> &Cb)
{
if (Ca.a == Cb.a && Ca.b==Cb.b)
return true;
else
return false;
}
int main(int argc, char **argv)
{
float a,b;
a=2.;
b=3.;
Complex<float> ci(a,b);
Complex<float> cj(a,b);
if(ci==cj)
cout<< " same Numbers "<<endl;
else
cout << "numbers not the same" << endl;
cout<< ci.Real() << " + " << ci.Imag() << endl;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="tComplex.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="tComplex.cc"
I2luY2x1ZGUgPGlvc3RyZWFtLmg+Ci8vI2luY2x1ZGUgIkNvbXBsZXguaCIKCnRlbXBsYXRlIDxj
bGFzcyBUPiAKICAgY2xhc3MgQ29tcGxleAp7CiAgcHVibGljOgogIAogIFQgYSxiOwogIAogIENv
bXBsZXgoVCAsVCk7CiAgVCBSZWFsKCk7CiAgVCBJbWFnKCk7CiAgCiAgZnJpZW5kIGJvb2wgb3Bl
cmF0b3I9PShjb25zdCBDb21wbGV4IDxUPiAmLGNvbnN0IENvbXBsZXg8VD4gJik7CiAKIAoKICAK
fTsKdGVtcGxhdGUgPGNsYXNzIFQ+CkNvbXBsZXg8VD46OkNvbXBsZXgoVCB4LFQgeSkKeyAKICBh
ID0geDsKICBiID0geTsKICB9Cgp0ZW1wbGF0ZSA8Y2xhc3MgVD4gIApUIENvbXBsZXg8VD46OlJl
YWwoKQogIHsgCiAgICAgcmV0dXJuIGE7CiAgICAgfQoKCnRlbXBsYXRlIDxjbGFzcyBUPiAgICAg
IApUIENvbXBsZXg8VD46OkltYWcoKQogIHsgCiAgICAgcmV0dXJuIGI7CiAgICAgfSAgICAgCgoK
dGVtcGxhdGUgPGNsYXNzIFQ+CiBib29sIG9wZXJhdG9yID09KGNvbnN0IENvbXBsZXg8VD4gJkNh
LGNvbnN0IENvbXBsZXg8VD4gJkNiKQoKICB7CiAgICBpZiAoQ2EuYSA9PSBDYi5hICYmIENhLmI9
PUNiLmIpCiAgICAgIHJldHVybiB0cnVlOwogICAgZWxzZSAKICAgICAgcmV0dXJuIGZhbHNlOwp9
CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqKmFyZ3YpCnsKICAgIAogIGZsb2F0IGEsYjsKICBh
PTIuOwogIGI9My47CiAgCiAgQ29tcGxleDxmbG9hdD4gY2koYSxiKTsKICBDb21wbGV4PGZsb2F0
PiBjaihhLGIpOwogIAogIGlmKGNpPT1jaikKICAgIGNvdXQ8PCAiIHNhbWUgTnVtYmVycyAiPDxl
bmRsOwogIGVsc2UKICAgIGNvdXQgPDwgIm51bWJlcnMgbm90IHRoZSBzYW1lIiA8PCBlbmRsOwog
ICAKICAgIAogIGNvdXQ8PCBjaS5SZWFsKCkgPDwgIiArICIgPDwgY2kuSW1hZygpIDw8IGVuZGw7
ICAgCiAgfQo=
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/5962: g++ compile an link
@ 2002-03-29 12:21 mmitchel
0 siblings, 0 replies; 2+ messages in thread
From: mmitchel @ 2002-03-29 12:21 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, onofre
Synopsis: g++ compile an link
State-Changed-From-To: open->closed
State-Changed-By: mmitchel
State-Changed-When: Fri Mar 29 12:21:08 2002
State-Changed-Why:
Not a bug.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5962
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-03-29 20:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-14 4:36 c++/5962: g++ compile an link onofre
2002-03-29 12:21 mmitchel
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).