This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/880: Return type of type operator is not equivalent to return type of member function.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]