Boost logo

Boost :

Subject: Re: [boost] [system] Would it be possible to trial a breaking change to Boost.System and see what happens?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-01-13 15:35:35


On 01/13/18 18:20, Peter Dimov via Boost wrote:
>> Andrey Semashev wrote:
>>
>> > I don't think the standard requires this implementation. >
>> `system_category()` may return a pointer to a global caregory
>> instance, > which is initialized before `main`.
>>
>> You're not prohibited from calling system_category() before main, so
>> it has to work.
>
> You can see for yourself what happens in practice today:
> https://godbolt.org/g/1TfPQw
>
> The g++/clang++ generated code looks cleaner than that, but it's because
> it doesn't include system_category(). Here it is in libc++:
> https://github.com/llvm-mirror/libcxx/blob/master/src/system_error.cpp#L211
>
> MS's code is even more convoluted because their <system_error> works
> during process shutdown, after static destruction. But the magic static
> cost is the same in either case.

Here's the gist of what I propose:

https://godbolt.org/g/nSiEZZ

It's as optimal as it can get, IMHO.


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