Suspicious warning for fake int in PreviewLoader.cpp
Stephan Witt
st.witt at gmx.net
Fri Dec 16 06:24:14 UTC 2022
Am 16.12.2022 um 00:48 schrieb Richard Kimberly Heck <rikiheck at gmail.com>:
>
> On 12/15/22 17:02, Stephan Witt wrote:
>> Hi all,
>>
>> I’m seeing this warning with more modern Apple compilers for lyx-2.3.x:
>>
>> lyx-2.3.x/src/graphics/PreviewLoader.cpp:730:28: warning: result of '2^20' is 22; did you mean '1 << 20' (1048576)? [-Wxor-used-as-pow]
>> static atomic_int fake((2^20) + 1);
>> ~^~~
>> 1 << 20
>> lyx-2.3.x/src/graphics/PreviewLoader.cpp:730:28: note: replace expression with '0x2 ^ 20' or use 'xor' instead of '^' to silence this warning
>>
>> This was fixed in master. Shouldn’t the fix be backport to 2.3.x?
>
> I suppose, but I'm confused. Why is 2^20 = 22? Overflow? Or does ^ not mean what I thought it did?
The ^ operator is the bitwise exclusive or (XOR) - but the intended operation is probably power(2,20) aka 1 << 20.
Stephan
More information about the lyx-devel
mailing list