max0x7ba / atomic_queue

C++ lockless queue.
MIT License
1.47k stars 176 forks source link

Use unsigned constant to avoid sign-conversion error #47

Closed cxz66666 closed 1 year ago

cxz66666 commented 1 year ago

When I build atomic_queue with -Wall, I found following errors:

error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
     return or_equal(or_equal(x, u), rest...);
            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

So just use unsigned constant to avoid it!

max0x7ba commented 1 year ago

When I build atomic_queue with -Wall, I found following errors:

You provided no reproduction for the issue. Not sure what and how you build.

The benchmark and the unit tests in the continuous integration are built with -W{all,extra,error}, no errors.

max0x7ba commented 1 year ago

When I build atomic_queue with -Wall, I found following errors:

error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
     return or_equal(or_equal(x, u), rest...);
            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

The error message says it is caused by -Wsign-conversion, which is not part of -Wall.

-Wsign-conversion is rather toxic because it breaks perfectly well-formed code.