[cfe-dev] [RFC] automatic variable initialization

Kostya Serebryany via cfe-dev cfe-dev at lists.llvm.org
Fri Jan 18 10:44:17 PST 2019


On Wed, Jan 16, 2019 at 7:58 PM Richard Smith <richard at metafoo.co.uk> wrote:

> On Wed, 16 Jan 2019, 19:35 Kostya Serebryany via cfe-dev <
> cfe-dev at lists.llvm.org wrote:
>
>>
>>>
>>> Should main be involved, though?
>>>
>>
>> How else?
>>
>
> By putting the initialisation where it belongs, in the constructor.
>

As already discussed below, initializing in CTORs will also initialize heap
memory,
i.e. will have different performance characteristics.
Still a good idea.


>
> main() creates a local variable on stack and passes it's address to a
>> CTOR, that (in general case) is unknown at the point where we insert
>> initialization.
>>
>>
>>
>>> It's normally the job of the constructor to initialize the class
>>> members, and that's where the information about whether the members are
>>> uninitialised lives.
>>>
>>>>
>>>>>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190118/0c110552/attachment.html>


More information about the cfe-dev mailing list