Subject: Re: [boost] [TypeIndex] Peer review period for library acceptance begins, ending Thurs 21st Nov
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-11-14 10:01:44
On 11/13/2013 09:26 PM, Antony Polukhin wrote:
> 2013/11/14 Steven Watanabe <watanabesj_at_[hidden]>
>> On 11/12/2013 11:34 AM, Niall Douglas wrote:
>>> Boost community feedback is requested for the formal peer review of
>>> the TypeIndex library by Antony Polukhin. Feedback requested
>>> 1. Should this library be accepted into Boost?
>> No. This library should not be accepted into Boost
>> in its current form.
>> return static_cast<const boost::type_info&>(typeid(type));
>> This is undefined behavior, and there is no
>> way to make it correct.
> This is a necessary evil and it is harmless:
> * all the methods of std::type_info (except destructor) are non virtual, so
> for example calls to name() will call boost::type_info::name()
> * it is *undefined* which destructor (std::type_info or boost::type_info)
> will be called *but*:
> * boost::type_info contains no members, it's size must be equal to the
> size of std::type_info, so no harm if boost::type_info destructor won't be
> * destructor of std::type_info will be called anyway
No, it is not harmless. You cannot safely assume
that undefined behavior is ever harmless, just
because you can't think of anything that can go wrong.
In particular, the compiler is free to make assumptions
that can cause your code to miscompile with optimizations on.
> I can add assert to tests to ensure that sizeof(std::type_info) ==