public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/9489: gcc fails to find implicit conversion with template class
@ 2003-01-28 23:07 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-01-28 23:07 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jrestemeier, nobody
Synopsis: gcc fails to find implicit conversion with template class
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Jan 28 23:07:15 2003
State-Changed-Why:
This is in essence a duplicate of 9230: when does the
friend function become visible?
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9489
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/9489: gcc fails to find implicit conversion with template class
@ 2003-01-28 21:46 jrestemeier
0 siblings, 0 replies; 2+ messages in thread
From: jrestemeier @ 2003-01-28 21:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 9489
>Category: c++
>Synopsis: gcc fails to find implicit conversion with template class
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jan 28 21:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: jrestemeier@currantbun.com
>Release: Apple Computer, Inc. GCC version 1151, based on gcc version 3.1 20020420 (prerelease)
>Organization:
>Environment:
MacOS/X
>Description:
template<class T> class foo {
public:
T a, b;
foo & operator+=(const foo &rhs) {
a+=rhs.a;
b+=rhs.b;
return *this;
}
friend foo operator+(const foo &lhs, const foo &rhs) {
return foo(lhs)+=rhs;
}
};
template<class T>class bar {
public:
T ping, pong;
bar() {}
bar(const foo<T> & f) {
ping = f.a;
pong = f.b;
}
bar(int a, int b) {
ping = a;
pong = b;
}
operator foo<T>() const {
foo<T> f;
f.a = ping;
f.b = pong;
return f;
}
};
int main (int argc, const char * argv[]) {
// foo<int> f;
bar<int> a(1,2), b(3,4), c;
c=a+b;
return 0;
}
---
This fails with :
main.cpp: In function `int main(int, const char**)':
main.cpp:37: no match for `bar<int>& + bar<int>&' operator
remove the comment in front of "foo<int> f" and it compiles with just a warning about f beeing unused.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-01-28 23:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-28 23:07 c++/9489: gcc fails to find implicit conversion with template class bangerth
-- strict thread matches above, loose matches on Subject: below --
2003-01-28 21:46 jrestemeier
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).