This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Re: [PATCH 1/2] Add unit test to aarch64 prologue analyzer


On 11/30/2016 04:34 PM, Yao Qi wrote:
> On Wed, Nov 30, 2016 at 06:53:08AM -0500, Antoine Tremblay wrote:
>>>> Also I wonder if we need to specify the default constructor explicitly ?
>>>> Is there a rationale for it?
>>>>
>>>> It's never used too, unless you apply my previous comment.
>>>
>>> The instruction_reader_test default constructor is never used.  How
>>> about using "= delete"?
>>>
>>>     instruction_reader_test () = delete;
>>>     instruction_reader_test (std::initializer_list<uint32_t> init)
>>>       : insns{init} {}
>>
>> Yes that would be more appropriate if we're going to specify that.
>>
>> I just wrote a patch with a C++ class and did not include explicit
>> default constructors do you think we should make it a code convention to
>> explicitly specify their existence or non-existence (=default, =delete) ?
> 
> If you don't want default constructor to be used, "=delete" is useful,
> IMO, which tells compiler not to generate the default constructor.  The
> intention is quite clear that I don't want you to use the default
> constructor.

Note that if the class has a user-defined constructor, then the
default ctor is not generated at all.  So you don't need to delete
the default one then.  If I see a "=delete" in such case (as above),
I'll scratch my head wondering why the redundancy is there in the
first place, and maybe if so inclined that day remove the unnecessary
code as an obvious cleanup patch.  :-)

(deleted functions participate in overload resolution, so there's
a difference from the method not being defined, but I don't believe
that's what you were going for here.)

Thanks,
Pedro Alves


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