This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2007 18:31:42 -0000
- Subject: [Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
- References: <bug-33537-3264@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pluto at agmk dot net 2007-09-23 18:31 -------
(In reply to comment #0)
> If this function is called from GDB, and the called function modifies
> its argument, it will end up modifying the original copy.
> It's supposed to get a temporary copy.
compiler does the temporary copy. please look at this example:
$ cat 33537.cpp
struct X
{
X();
X( X const& );
int var;
};
int f( X arg )
{
arg.var = 0;
return arg.var;
}
int main()
{
X x;
f( x );
return 0;
}
at tree dump we see the temporary object passed to f(X) by reference:
int f(X) (arg)
{
arg->var = 0;
return 0;
}
int main() ()
{
struct X x;
struct X D.2360;
__comp_ctor (&x);
__comp_ctor (&D.2360, &x);
f (&D.2360);
return 0;
}
--
pluto at agmk dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pluto at agmk dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537