This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9748: c++ using "operator = ( const Foo& )" when it *should* use "operator = ( int )"
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, royce3 at ev1 dot net
- Date: 18 Feb 2003 20:27:53 -0000
- Subject: Re: c++/9748: c++ using "operator = ( const Foo& )" when it *should* use "operator = ( int )"
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, royce3 at ev1 dot net, gcc-gnats at gcc dot gnu dot org
Synopsis: c++ using "operator = ( const Foo& )" when it *should* use "operator = ( int )"
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Feb 18 20:27:53 2003
State-Changed-Why:
Not a bug.
If you use the assignment for
Foo foo = 1;
then a conversion constructor and a copy constructor needs
to be accessible (the compiler is allowed to elide the
temporary, though).
In strict ISO mode, Intel's icc also agrees:
tmp/g> icc -Xc -ansi x.cc
x.cc(36): warning #734: "Foo::Foo(const Foo &)", required for copy that was eliminated, is inaccessible
Foo foo = returnsInt();
^
What you quote about temporaries has nothing to do with
this.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9748