This is the mail archive of the gcc-bugs@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]

[Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type



------- 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


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