Boost C++ Libraries: Ticket #6060: Warning generated in SNC C++ compiler by use of __sync_fetch_and_add https://svn.boost.org/trac10/ticket/6060 <p> When compiling code that uses boost/shared_array.hpp in SNC C++ compiler, the following warning is generated: </p> <p> ../../SDKs/Boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp(48,37): warning 68: integer conversion resulted in a change of sign </p> <p> in this line: </p> <pre class="wiki">return __sync_fetch_and_add( pw, -1 ); </pre><p> I've managed to fix the warning by replacing "<span class="underline">sync_fetch_and_add" with "</span>sync_fetch_and_sub", and changing the second argument from "-1" to "1". I've included a patch, hope it helps. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6060 Trac 1.4.3 Fernando Diaz <fdiaza@…> Tue, 25 Oct 2011 20:31:08 GMT attachment set https://svn.boost.org/trac10/ticket/6060 https://svn.boost.org/trac10/ticket/6060 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">snc_warning.patch</span> </li> </ul> <p> Proposed change to fix warning </p> Ticket Peter Dimov Tue, 25 Oct 2011 21:00:26 GMT <link>https://svn.boost.org/trac10/ticket/6060#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6060#comment:1</guid> <description> <p> This is a problem with SNC. The prototype of __sync_fetch_and_add is </p> <p> <code>type __sync_fetch_and_add (type *ptr, type value, ...)</code> </p> <p> 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. </p> </description> <category>Ticket</category> </item> <item> <author>Fernando Diaz <fdiaza@…></author> <pubDate>Wed, 26 Oct 2011 12:59:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6060#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6060#comment:2</guid> <description> <p> I see. In any case, am I correct in seeing </p> <p> <code>__sync_fetch_and_add( pw, -1 );</code> </p> <p> and </p> <p> <code>__sync_fetch_and_sub( pw, 1 );</code> </p> <p> 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! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Mon, 07 Nov 2011 18:32:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6060#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6060#comment:3</guid> <description> <p> 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 <code>__sync_fetch_and_sub</code> in an <code>#ifdef __SNC__</code>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Fri, 13 Dec 2013 22:26:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6060#comment:4 https://svn.boost.org/trac10/ticket/6060#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I'm closing this as too old and probably no longer relevant. Please reopen if this is not the case. </p> Ticket