public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bangerth@dealii.org
To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, johan@tiq.com,
	nobody@gcc.gnu.org
Subject: Re: c++/880: Return type of type operator is not equivalent to return type of member function.
Date: Sun, 10 Nov 2002 12:26:00 -0000	[thread overview]
Message-ID: <20021110202627.21262.qmail@sources.redhat.com> (raw)

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


                 reply	other threads:[~2002-11-10 20:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021110202627.21262.qmail@sources.redhat.com \
    --to=bangerth@dealii.org \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=johan@tiq.com \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).