[vlc-devel] [PATCH] d3d11_adjust: Pass a non-const pointer to atomic_load

Rémi Denis-Courmont remi at remlab.net
Mon Feb 19 15:19:09 CET 2018


Le 19 février 2018 14:57:10 GMT+02:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>On Mon, Feb 19, 2018, at 1:53 PM, Steve Lhomme wrote:
>> Le 19/02/2018 à 13:42, Martin Storsjö a écrit :
>> > This fixes compilation with clang, which previously errored
>> > out with this message:
>> >
>> > error: address argument to atomic operation must be a pointer to
>non-const _Atomic
>> >        type ('const atomic_int *' (aka 'const _Atomic(int) *')
>invalid)
>> >      int level = atomic_load(&p_level->level);
>> >                  ^           ~~~~~~~~~~~~~~~
>> 
>> This is odd as atomic_load() doesn't change the internal value. In
>C++11 
>> atomic::load() is a const method.
>> But feel free to push.
>> 
>
>That's what I thought as well, but the C11 standard specifies the
>parameter to be a pointer to a non-const volatile value. Actually the
>documentation on cppreference.com seems invalid to that regard.
>
>
>-- 
>  Hugo Beauzée-Luyssen
>  hugo at beauzee.fr
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

We have already had the same argument about mtx_lock. There is nothing wrong with the standard: if the value can change asynchronously from another thread, it is not constant even if the calling thread does not modify the value.

IMO, this is a perfectly sane interpretation of constance.

The other interpretation would be that the calling thread cannot modify the value except via aliases. It is sane too, but that is not the one conventionally used in C.
-- 
Remi Denis-Courmont


More information about the vlc-devel mailing list