[zeromq-dev] Casting bug in atomic_counter.hpp - probably only on non x86 or ARM CPUs.

Dr. David Kirkby (Kirkby Microwave Ltd) drkirkby at kirkbymicrowave.co.uk
Tue Jun 2 15:35:47 CEST 2015

On 2 June 2015 at 13:07, Steven McCoy <steven.mccoy at miru.hk> wrote:
> On 2 June 2015 at 07:51, Dr. David Kirkby (Kirkby Microwave Ltd)
> <drkirkby at kirkbymicrowave.co.uk> wrote:
>> atomic_counter.hpp:87:71: error: invalid conversion from 'volatile
>> integer_t* {aka volatile unsigned int*}' to 'uint32_t* {aka unsigned
>> int*}' [-fpermissive]
>> This is line 87 which the error refers to.
>> integer_t new_value = atomic_add_32_nv (&value, increment_);
> This is correct for Oracle Studio,
> https://docs.oracle.com/cd/E19253-01/816-5180/6mbbf01oj/index.html
> This looks like a defective GCC, I don't think Oracle GCC 3 has these
> problems.
> You can try using the GCC intrinsics in preference for this particular
> compiler version.
> --
> Steve-o

But is the problem not that the argument is volatile, and the function
definition does not include volatile?

I know C, but not C++, but from what I can make of the code, it seems
to be missing a cast to me.

Line 176 of the header file has

volatile integer_t value;

which to me indicates the variable "value" is declared volatile, but
it is being passed to a function that is not expecting volatile.


More information about the zeromq-dev mailing list