On 10/1/21 11:44 AM, Florian Weimer wrote:
* Martin Sebor via Gcc:

I'd expect TYPE_NEEDS_CONSTRUCTING to be non-zero in the middle end
for any C++ type with a user-defined ctor, but in some of my testing
I see it's actually zero for std::string, at least in some instances
(but nonzero for other types with ctors).  Is there something special
about std::string that makes it so?  (If this is intentional, how can
I create my own type that has a user-defined ctor and also a zero
TYPE_NEEDS_CONSTRUCTING?)

I assume by writing an explicit default constructor:

   T() = default;

Yes, but in a class that also defines (non-defaulted) ctors
TYPE_NEEDS_CONSTRUCTING() is nonzero.

I'm looking for a type that defines a ctor (the above just declares
one) that has a zero for TYPE_NEEDS_CONSTRUCTING(T).  GCC documents
the macro as:

/* Indicates that objects of this type must be initialized by calling a
   function when they are created.  */

So assuming TYPE_NEEDS_CONSTRUCTING(std::string) is supposed to return
zero (i.e., it's not a bug or some oddity I'm seeing) I want to know
how to define a class like it, with one or more user-defined ctors,
for which TYPE_NEEDS_CONSTRUCTING() also returns zero.  Otherwise,
if it's a bug, I'll see if I can come up with a test case for it.

Martin

Reply via email to