Boost logo

Boost :

Subject: Re: [boost] [parameter] aux_/void.hpp: potential undefined behavior
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-11-05 16:27:07


on Thu Nov 03 2011, Krzysztof Czainski <1czajnik-AT-gmail.com> wrote:

> 2011/11/3 Stewart, Robert <Robert.Stewart_at_[hidden]>
>
>> Krzysztof Czainski wrote:
>> >
>> > struct void_ {};
>> >
>> > namespace aux
>> > {
>> > inline void_& void_reference()
>> > {
>> > static void_ instance; // (1)
>> > return instance;
>> > }
>> [snip]
>> > My question is: is it allowed to use an instance of an
>> > uninitialized empty struct?
>>
>> That uses the implicit default constructor provided by the compiler which,
>> of course, does nothing. instance is not uninitialized.
>>
>
> Oh, makes sense, thanks.
>
> So then, don't you think it's better to use static initialization? Or maybe
> it doesn't matter?

Yes, it would be better if these things followed the pattern used in
proto for terminals, with static initialization.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk