public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
@ 2007-09-23 15:18 drow at gcc dot gnu dot org
2007-09-23 17:07 ` [Bug debug/33537] " bangerth at dealii dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: drow at gcc dot gnu dot org @ 2007-09-23 15:18 UTC (permalink / raw)
To: gcc-bugs
Compile the code below using g++ -g, load the object into gdb, and 'ptype foo'.
You will see that the type of foo is 'int (Obj &)'. 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.
This changed sometime between g++ 3.3 and g++ 4.0.
class Obj {
public:
Obj ();
Obj (const Obj &);
~Obj ();
int var[2];
};
int foo (Obj arg)
{
return arg.var[0] + arg.var[1];
}
int main() { return 0; }
Obj::Obj ()
{
var[0] = 1;
var[1] = 2;
}
Obj::Obj (const Obj &obj)
{
var[0] = obj.var[0];
var[1] = obj.var[1];
}
Obj::~Obj ()
{
}
--
Summary: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by
invisible reference have wrong type
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: drow at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
@ 2007-09-23 17:07 ` bangerth at dealii dot org
2007-09-23 17:49 ` drow at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2007-09-23 17:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from bangerth at dealii dot org 2007-09-23 17:07 -------
I get the same output
(gdb) ptype foo
type = int (Obj &)
for all compilers I tried here, i.e. gcc versions 2.95, 3.2.3, 3.3.6, 3.4.6
and 4.1.2. This is with gdb 6.5.
On the other hand, when using icc10 and Sun Studio, I get this:
(gdb) ptype foo
type = int (Obj)
which appears correct. So I can confirm that this appears to be a bug.
I'm not sure yet about the regression status: Can you re-check whether you
indeed got the correct results with pre-4.0 versions of gcc?
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-09-23 17:07:02
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
2007-09-23 17:07 ` [Bug debug/33537] " bangerth at dealii dot org
@ 2007-09-23 17:49 ` drow at gcc dot gnu dot org
2007-09-23 18:31 ` pluto at agmk dot net
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: drow at gcc dot gnu dot org @ 2007-09-23 17:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from drow at gcc dot gnu dot org 2007-09-23 17:49 -------
I got the correct result on amd64 with g++-3.3 (GCC) 3.3.6 (Debian 1:3.3.6-15).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
2007-09-23 17:07 ` [Bug debug/33537] " bangerth at dealii dot org
2007-09-23 17:49 ` drow at gcc dot gnu dot org
@ 2007-09-23 18:31 ` pluto at agmk dot net
2007-09-23 18:40 ` drow at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pluto at agmk dot net @ 2007-09-23 18:31 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-09-23 18:31 ` pluto at agmk dot net
@ 2007-09-23 18:40 ` drow at gcc dot gnu dot org
2007-09-26 19:08 ` [Bug debug/33537] [4.1/4.2/4.3 " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: drow at gcc dot gnu dot org @ 2007-09-23 18:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from drow at gcc dot gnu dot org 2007-09-23 18:40 -------
Subject: Re: [4.0/4.1/4.2/4.3 regression] C++ arguments
passed by invisible reference have wrong type
On Sun, Sep 23, 2007 at 06:31:42PM -0000, pluto at agmk dot net wrote:
> > 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:
That's why the bug report said "from GDB". It's a debug info bug, not
a C++ wrong-code bug.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-09-23 18:40 ` drow at gcc dot gnu dot org
@ 2007-09-26 19:08 ` pinskia at gcc dot gnu dot org
2007-09-28 4:14 ` mmitchel at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-26 19:08 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.0/4.1/4.2/4.3 regression]|[4.1/4.2/4.3 regression] C++
|C++ arguments passed by |arguments passed by
|invisible reference have |invisible reference have
|wrong type |wrong type
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (4 preceding siblings ...)
2007-09-26 19:08 ` [Bug debug/33537] [4.1/4.2/4.3 " pinskia at gcc dot gnu dot org
@ 2007-09-28 4:14 ` mmitchel at gcc dot gnu dot org
2007-10-31 15:59 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-09-28 4:14 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (5 preceding siblings ...)
2007-09-28 4:14 ` mmitchel at gcc dot gnu dot org
@ 2007-10-31 15:59 ` jakub at gcc dot gnu dot org
2007-11-01 10:18 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-10-31 15:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2007-10-31 15:58 -------
dwarf2out.c needs to handle DECL_BY_REFERENCE PARM_DECLs (and perhaps also
RESULT_DECLs).
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-09-23 17:07:02 |2007-10-31 15:58:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (6 preceding siblings ...)
2007-10-31 15:59 ` jakub at gcc dot gnu dot org
@ 2007-11-01 10:18 ` jakub at gcc dot gnu dot org
2007-11-01 10:19 ` [Bug debug/33537] [4.1/4.2 " jakub at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-01 10:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jakub at gcc dot gnu dot org 2007-11-01 10:17 -------
Subject: Bug 33537
Author: jakub
Date: Thu Nov 1 10:17:42 2007
New Revision: 129820
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129820
Log:
PR debug/33537
* dwarf2out.c (gen_formal_parameter_die, gen_variable_die,
gen_decl_die): Use TREE_TYPE (TREE_TYPE (decl)) as type
rather than TREE_TYPE (decl) if DECL_BY_REFERENCE (decl).
Modified:
trunk/gcc/ChangeLog
trunk/gcc/dwarf2out.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.1/4.2 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (7 preceding siblings ...)
2007-11-01 10:18 ` jakub at gcc dot gnu dot org
@ 2007-11-01 10:19 ` jakub at gcc dot gnu dot org
2007-11-01 17:37 ` jan dot kratochvil at redhat dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-01 10:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jakub at gcc dot gnu dot org 2007-11-01 10:19 -------
Fixed on the trunk so far.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2/4.3 regression] C++|[4.1/4.2 regression] C++
|arguments passed by |arguments passed by
|invisible reference have |invisible reference have
|wrong type |wrong type
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.1/4.2 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (8 preceding siblings ...)
2007-11-01 10:19 ` [Bug debug/33537] [4.1/4.2 " jakub at gcc dot gnu dot org
@ 2007-11-01 17:37 ` jan dot kratochvil at redhat dot com
2008-07-04 22:18 ` [Bug debug/33537] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 22:27 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2007-11-01 17:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jan dot kratochvil at redhat dot com 2007-11-01 17:37 -------
ptype testcase is now in GDB as: gdb/testsuite/gdb.cp/arg-reference.exp
(GDB still does not create the temporary copy during a call from GDB itself.)
--
jan dot kratochvil at redhat dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jan dot kratochvil at redhat
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.2 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (9 preceding siblings ...)
2007-11-01 17:37 ` jan dot kratochvil at redhat dot com
@ 2008-07-04 22:18 ` jsm28 at gcc dot gnu dot org
2009-03-30 22:27 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jsm28 at gcc dot gnu dot org 2008-07-04 22:18 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2 regression] C++ |[4.2 regression] C++
|arguments passed by |arguments passed by
|invisible reference have |invisible reference have
|wrong type |wrong type
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug debug/33537] [4.2 regression] C++ arguments passed by invisible reference have wrong type
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
` (10 preceding siblings ...)
2008-07-04 22:18 ` [Bug debug/33537] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 22:27 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 22:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jsm28 at gcc dot gnu dot org 2009-03-30 22:26 -------
Closing 4.2 branch, fixed in 4.3.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to fail| |4.2.5
Known to work| |4.3.0
Resolution| |FIXED
Target Milestone|4.2.5 |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33537
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-03-30 22:27 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-23 15:18 [Bug debug/33537] New: [4.0/4.1/4.2/4.3 regression] C++ arguments passed by invisible reference have wrong type drow at gcc dot gnu dot org
2007-09-23 17:07 ` [Bug debug/33537] " bangerth at dealii dot org
2007-09-23 17:49 ` drow at gcc dot gnu dot org
2007-09-23 18:31 ` pluto at agmk dot net
2007-09-23 18:40 ` drow at gcc dot gnu dot org
2007-09-26 19:08 ` [Bug debug/33537] [4.1/4.2/4.3 " pinskia at gcc dot gnu dot org
2007-09-28 4:14 ` mmitchel at gcc dot gnu dot org
2007-10-31 15:59 ` jakub at gcc dot gnu dot org
2007-11-01 10:18 ` jakub at gcc dot gnu dot org
2007-11-01 10:19 ` [Bug debug/33537] [4.1/4.2 " jakub at gcc dot gnu dot org
2007-11-01 17:37 ` jan dot kratochvil at redhat dot com
2008-07-04 22:18 ` [Bug debug/33537] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 22:27 ` jsm28 at gcc dot gnu dot org
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).