diff mbox

[4/4] PR c++/13403 and PR c++/15154: Fix gnuv3_pass_by_reference to treat dynamic classes as non-trivial

Message ID CAGyQ6gwUDdJh+oUxJxhgSXfY90cp2hkh-+mN0wEcJp90naBXog@mail.gmail.com
State New
Headers show

Commit Message

Siva Chandra Reddy Sept. 11, 2014, 6:38 p.m. UTC
gdb/ChangeLog:

2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>

        * gnu-v3-abi.c (gnuv3_pass_by_reference): Treat dynamic classes
        as non-trivial.

Comments

Doug Evans Sept. 29, 2014, 8:08 a.m. UTC | #1
On Thu, Sep 11, 2014 at 11:38 AM, Siva Chandra <sivachandra@google.com> wrote:
> gdb/ChangeLog:
>
> 2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>
>
>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Treat dynamic classes
>         as non-trivial.

This looks ok to me.
I couldn't find anything in the ABI to guide me (could certainly have
missed it), though it seems reasonable and it does fix the testcase.
Siva Chandra Reddy Sept. 29, 2014, 10:29 p.m. UTC | #2
On Mon, Sep 29, 2014 at 1:08 AM, Doug Evans <dje@google.com> wrote:
>> 2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>
>>
>>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Treat dynamic classes
>>         as non-trivial.
>
> This looks ok to me.
> I couldn't find anything in the ABI to guide me (could certainly have
> missed it), though it seems reasonable and it does fix the testcase.

The ABI defers the definition of triviality of copy constructors and
destructors to the C++ 98 final draft standard. The point under
question in this patch is under -6- here:
http://www.kouzdra.org/page/docs/isocpp/special.html#class.copy
Doug Evans Oct. 14, 2014, 9:01 p.m. UTC | #3
Siva Chandra writes:
 > On Mon, Sep 29, 2014 at 1:08 AM, Doug Evans <dje@google.com> wrote:
 > >> 2014-09-11  Siva Chandra Reddy  <sivachandra@google.com>
 > >>
 > >>         * gnu-v3-abi.c (gnuv3_pass_by_reference): Treat dynamic classes
 > >>         as non-trivial.
 > >
 > > This looks ok to me.
 > > I couldn't find anything in the ABI to guide me (could certainly have
 > > missed it), though it seems reasonable and it does fix the testcase.
 > 
 > The ABI defers the definition of triviality of copy constructors and
 > destructors to the C++ 98 final draft standard. The point under
 > question in this patch is under -6- here:
 > http://www.kouzdra.org/page/docs/isocpp/special.html#class.copy

Ah.  Thanks for the reference.

LGTM with one nit.

It'd be really nice to include a reference to the spec here.
I don't know about others, but this stuff is not the kind of
thing I tend to keep in cache, and when reading such code
it's really nice to be able to find the relevant sections
of the spec without any effort.

Does the following make sense?

+  /* A dynamic class has a non-trivial copy constructor.
+     See c++98 section 12.8 Copying class objects [class.copy].  */
+  if (gnuv3_dynamic_class (type))
+    return 1;
+
Siva Chandra Reddy Oct. 15, 2014, 1:10 a.m. UTC | #4
On Tue, Oct 14, 2014 at 2:01 PM, Doug Evans <dje@google.com> wrote:
> It'd be really nice to include a reference to the spec here.
> I don't know about others, but this stuff is not the kind of
> thing I tend to keep in cache, and when reading such code
> it's really nice to be able to find the relevant sections
> of the spec without any effort.
>
> Does the following make sense?
>
> +  /* A dynamic class has a non-trivial copy constructor.
> +     See c++98 section 12.8 Copying class objects [class.copy].  */
> +  if (gnuv3_dynamic_class (type))
> +    return 1;
> +

Thanks Doug. I will push this patch set after adding the above comment.
diff mbox

Patch

diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index a79a6a9..5ce2fb5 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1282,6 +1282,9 @@  gnuv3_pass_by_reference (struct type *type)
       && TYPE_CODE (type) != TYPE_CODE_UNION)
     return 0;
 
+  if (gnuv3_dynamic_class (type))
+    return 1;
+
   for (fieldnum = 0; fieldnum < TYPE_NFN_FIELDS (type); fieldnum++)
     for (fieldelem = 0; fieldelem < TYPE_FN_FIELDLIST_LENGTH (type, fieldnum);
 	 fieldelem++)