From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Class-ify ptid_t
Date: Fri, 07 Apr 2017 01:56:00 -0000 [thread overview]
Message-ID: <c9500f9a-5358-2fc0-e75d-718e5a053da9@redhat.com> (raw)
In-Reply-To: <01ede052c2a7f8717e338e3e4de20a41@polymtl.ca>
On 04/07/2017 01:04 AM, Simon Marchi wrote:
>> Hmm, I think this comment too lax. There _is_ a reason this type
>> must remain POD for the time being. So I think that's what we
>> should say here:
>>
>> /* Check that the ptid_t class is POD.
>>
>> This is a requirement for a long as we have ptids embedded in
>> structures allocated with malloc. */
>
> Ah, makes sense. I was only thinking about the instances where ptid_t
> is embedded in structures allocated statically. In those cases,
> compilation would fail anyway, which is why I didn't really see the
> point of that test.
Actually, non-PODs in structures allocated statically is perfectly fine.
The compiler arranges for the objects to have their constructors
called. That's why we can e.g., have global std::vector objects
or function local static std::string objects (both non-PODs), etc.
So we could e.g., have a default ptid_t ctor that initializes
the pid/lwpid/tid fields to zeros instead of leaving them undefined.
Except, if we did that, then the ctor would no longer be trivial, and
so the type would no longer be POD, meaning we couldn't create a ptid
with malloc and use it straight away. We'd have to either call
the ctor manually with placement new after malloc to bring to
object to life, and call the dtor manually too (but that's off course
cumbersome), or we'd have to use normal new/delete instead, which is
the natural thing to do, but we're a bit far away from doing
that everywhere.
> But of course, it's important for malloc'ed
> structures as well, for which we get now error/warning.
Hmm, I'm not quite picturing what error/warning we now get?
Thanks,
Pedro Alves
next prev parent reply other threads:[~2017-04-07 1:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 19:03 Simon Marchi
2017-04-06 22:23 ` Pedro Alves
2017-04-07 0:04 ` Simon Marchi
2017-04-07 1:56 ` Pedro Alves [this message]
2017-04-07 3:21 ` Simon Marchi
2017-04-07 3:34 ` [pushed] " Simon Marchi
2017-04-07 9:25 ` [PATCH v2] " Philipp Rudo
2017-04-07 10:48 ` Pedro Alves
2017-04-07 14:34 ` Simon Marchi
2017-04-07 14:35 ` [pushed] ptid-selftests: Fix erroneous assert messages Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9500f9a-5358-2fc0-e75d-718e5a053da9@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox