Boost logo

Boost :

Subject: Re: [boost] [system] Would it be possible to trial a breaking change to Boost.System and see what happens?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2018-01-14 01:20:55


>> Peter's LWG defect resolution - as far as I understand it - needs some
>> extra compiler magic in the form of Immortalize.
>
> No, you're reading that incorrectly, it requires no compiler magic, it's
> implementable today. In the typical case it's just
>
> extern const __system_category_impl __syscat;
>
> constexpr error_category const& system_category()
> {
>    return __syscat;
> }
>
> When I proposed that, Billy O'Neal from MS objected that their
> system_category does extra "immortalization" so constexpr is
> unimplementable. So I gave a proof of concept of how their
> "immortalization" can be implemented to still be constexpr.
>
> I should probably just add the relevant constexpr's to Boost.System.

How do you guarantee that only one instance of an error category will
ever exist in the process?

If it's allowable to constexpr, I don't see how that's possible. I'd
love to be corrected due to ignorance.

MSVC's Immortalize is a directive to the VC runtime to ensure a single
instance ever. It really cannot be made constexpr because it uses a
runtime lookup table. At least, that's how STL explained it to me.

You can see some godbolt on this at https://godbolt.org/g/3TtFsu. Search
for std::_Immortalize<std::_System_error_category>.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

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