public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/880: Return type of type operator is not equivalent to return type of member function.
@ 2002-11-10 12:26 bangerth
0 siblings, 0 replies; only message in thread
From: bangerth @ 2002-11-10 12:26 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, johan, nobody
Synopsis: Return type of type operator is not equivalent to return type of member function.
State-Changed-From-To: analyzed->closed
State-Changed-By: bangerth
State-Changed-When: Sun Nov 10 12:26:25 2002
State-Changed-Why:
The array assignment extension seems to have gone, and the
code now produces consistent messages. With this code:
-----------------------------------
typedef float vec2_t[2];
class vec2 {
private:
vec2_t v;
public:
operator vec2_t & () { return v; }
vec2_t & asvec2_t () { return v;}
};
vec2_t & func (vec2_t & v) {
return v;
}
int main (int argc, char **argv) {
vec2_t U, V;
vec2 v;
U = V; // array-to-array copy
float f = v[0]; // implicit call to vec2::operator vec2_t & ()
U = v.asvec2_t(); // explicit conversion
U = func (v); // implicit call to vec2::operator vec2_t & ()
U = v; // Error: "incompatible types in assignment of
// `vec2' to `float[2]'". Now this is inconsistent
// behaviour and seems to me as a bug.
}
------------------------------------
I now get:
-------------------------------
tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/c++ -c cpptest.cpp
cpptest.cpp: In function `int main(int, char**)':
cpptest.cpp:20: error: ISO C++ forbids assignment of arrays
cpptest.cpp:22: error: ISO C++ forbids assignment of arrays
cpptest.cpp:23: error: ISO C++ forbids assignment of arrays
cpptest.cpp:24: error: incompatible types in assignment of `vec2' to `float[2]'
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=880
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-10 20:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-10 12:26 c++/880: Return type of type operator is not equivalent to return type of member function bangerth
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).