public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6807: G++ doesn't recognize templated reference conversion operators
@ 2002-09-14 15:28 nathan
0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-09-14 15:28 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, squell
Synopsis: G++ doesn't recognize templated reference conversion operators
State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Sat Sep 14 15:28:40 2002
State-Changed-Why:
same as pr 383
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6807
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/6807: G++ doesn't recognize templated reference conversion operators
@ 2002-05-24 18:56 squell
0 siblings, 0 replies; 2+ messages in thread
From: squell @ 2002-05-24 18:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 6807
>Category: c++
>Synopsis: G++ doesn't recognize templated reference conversion operators
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Fri May 24 18:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: squell@tfz.net
>Release: g++ 3.1.0
>Organization:
>Environment:
Reading specs from c:/djgpp/lib/gcc-lib/djgpp/3.1/specs
Configured with: ../configure i586-pc-msdosdjgpp --prefix=/dev/env/DJDIR --disable-nls
Thread model: single
gcc version 3.1
>Description:
The code below should be pretty clear.
Note that even though line 16 does not give a diagnostic, the conversion operator defined still doesn't get called, so a hard typecast is performed, which is not what is wanted.
It's interesting to see that if the class "blaat" is instead equipped with a non-template "operator int&()" member, the only line which is rejected by the compiler is line 13. :)
At the very least, this does not comply with 14.5.2/4.
test.cpp: In function `int main()':
test.cpp:12: cannot convert `blaat' to `int' in initialization
test.cpp:14: no matching function for call to `blaat::operator int&()'
test.cpp:15: `struct blaat' used where a `int' was expected
test.cpp:17: could not convert `H' to `int&'
test.cpp:7: in passing argument 1 of `void foo(int&)'
>How-To-Repeat:
struct blaat {
template<class T> operator T&()
{
}
};
void foo(int&) { }
int main()
{
blaat H;
int a = H;
int b = H.operator int(); // this is ok ??
int c = H.operator int&();
int d = (int)H;
int e = (int&)H; // conversion isn't called
foo(H);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-09-14 22:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-14 15:28 c++/6807: G++ doesn't recognize templated reference conversion operators nathan
-- strict thread matches above, loose matches on Subject: below --
2002-05-24 18:56 squell
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).