Opened 11 years ago
Closed 9 years ago
#6060 closed Patches (wontfix)
Warning generated in SNC C++ compiler by use of __sync_fetch_and_add
Reported by: | Owned by: | Peter Dimov | |
---|---|---|---|
Milestone: | To Be Determined | Component: | smart_ptr |
Version: | Boost 1.47.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
When compiling code that uses boost/shared_array.hpp in SNC C++ compiler, the following warning is generated:
../../SDKs/Boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp(48,37): warning 68: integer conversion resulted in a change of sign
in this line:
return __sync_fetch_and_add( pw, -1 );
I've managed to fix the warning by replacing "sync_fetch_and_add" with "sync_fetch_and_sub", and changing the second argument from "-1" to "1". I've included a patch, hope it helps.
Attachments (1)
Change History (5)
by , 11 years ago
Attachment: | snc_warning.patch added |
---|
comment:1 by , 11 years ago
This is a problem with SNC. The prototype of __sync_fetch_and_add is
type __sync_fetch_and_add (type *ptr, type value, ...)
i.e. the second argument should be the same type as the first, which, in shared_ptr's code, is sp_int32_t, a signed integer.
comment:2 by , 11 years ago
I see. In any case, am I correct in seeing
__sync_fetch_and_add( pw, -1 );
and
__sync_fetch_and_sub( pw, 1 );
as interchangeable? Because if the change is correct, but cannot be incorporated into boost, I could keep it on my side and reapply it each time boost is updated. Thanks!
comment:3 by , 11 years ago
They should be interchangeable, but the first one has already been tested and the replacement has not, so I'm a bit reluctant to change it unconditionally. Have you tried reporting this as a problem to the SNC folks? I hear that they're quite responsive. If they don't want to eliminate the warning, we could add __sync_fetch_and_sub
in an #ifdef __SNC__
.
comment:4 by , 9 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I'm closing this as too old and probably no longer relevant. Please reopen if this is not the case.
Proposed change to fix warning