Boost C++ Libraries: Ticket #7814: Signal 6 coredump on lexical_cast with gcc option trapv https://svn.boost.org/trac10/ticket/7814 <p> When compiling with g++ and option -ftrapv (trap overflow errors), a simple lexical_cast of a negative value causes a signal 6 dump: </p> <p> boost::lexical_cast&lt;long&gt;(std::string("-3333")); </p> <p> However, casting to double works fine. </p> <p> We're currently using gcc 4.7.1 on a <a class="missing wiki">OpenSuse</a> 12.1 platform. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7814 Trac 1.4.3 Antony Polukhin Thu, 20 Dec 2012 19:07:16 GMT status changed https://svn.boost.org/trac10/ticket/7814#comment:1 https://svn.boost.org/trac10/ticket/7814#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket alexey kutumov <alexey.kutumov@…> Sun, 23 Dec 2012 06:15:12 GMT attachment set https://svn.boost.org/trac10/ticket/7814 https://svn.boost.org/trac10/ticket/7814 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">7814.patch</span> </li> </ul> Ticket alexey kutumov <alexey.kutumov@…> Sun, 23 Dec 2012 06:20:21 GMT <link>https://svn.boost.org/trac10/ticket/7814#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:2</guid> <description> <p> The problem is in numeric_limits::min, because negating of minimum value of signed type is not representable as signed type (but representable as unsigned), so this line is incorrect: </p> <blockquote> <p> utype const comp_val = static_cast&lt;utype&gt;(-(std::numeric_limits&lt;Type&gt;::min)()); </p> </blockquote> <p> Patch 7814.patch solves this problem </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 23 Dec 2012 08:08:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7814#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:3</guid> <description> <p> That is not the only place where the problem occurs. There are several more places, where unary negation occurs, and they also need fixes (however they occur only when min/max value for a number is casted). Fast fixes did not help, because even some functions from std namespace trigger coredump. </p> <p> I am afraid, that this issue won't be fixed in boost 1.53, but I'll try to find a good solution for the problem till 1.54 </p> </description> <category>Ticket</category> </item> <item> <author>alexey kutumov <alexey.kutumov@…></author> <pubDate>Sun, 23 Dec 2012 15:36:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7814#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7814#comment:3" title="Comment 3">apolukhin</a>: </p> <blockquote class="citation"> <p> Fast fixes did not help, because even some functions from std namespace trigger coredump. </p> </blockquote> <p> Could you give example (related to lexical_cast) when coredump occurs </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 23 Dec 2012 15:38:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7814#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:5</guid> <description> <p> I've added a patch, that fixes all the issues (even on clang, which is more strict in some cases). This patch is also fixes some warnings on VC++. I'll commit it after it passes all the tests on VC++ without a warning and fix for <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7799" title="#7799: Bugs: std::array optimizations are not used (closed: fixed)">#7799</a> will be merged to release branch. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 23 Dec 2012 15:50:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7814#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7814#comment:4" title="Comment 4">alexey kutumov &lt;alexey.kutumov@…&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7814#comment:3" title="Comment 3">apolukhin</a>: </p> <blockquote class="citation"> <p> Fast fixes did not help, because even some functions from std namespace trigger coredump. </p> </blockquote> <p> Could you give example (related to lexical_cast) when coredump occurs </p> </blockquote> <p> It was some code like: </p> <pre class="wiki">template &lt;class T&gt; void test_impl() { typedef std::numeric_limits&lt;T&gt; limits; boost::lexical_cast&lt;std::string&gt;((limits::min)()); boost::lexical_cast&lt;std::string&gt;((limits::max)()); // boost::lexical_cast&lt;T&gt;("lexical representation of limits::min or limits::max"); } int main() { test_impl&lt;int&gt;(); test_impl&lt;unsigned int&gt;(); boost::lexical_cast&lt;int&gt;(0.0f); // Fails only on `clang -ftrapv` } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 23 Dec 2012 20:50:44 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/7814 https://svn.boost.org/trac10/ticket/7814 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">lexical_cast.hpp.patch</span> </li> </ul> <p> More generic patch </p> Ticket Antony Polukhin Sun, 23 Dec 2012 20:53:27 GMT severity changed; milestone deleted https://svn.boost.org/trac10/ticket/7814#comment:7 https://svn.boost.org/trac10/ticket/7814#comment:7 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Regression</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">To Be Determined</span> </li> </ul> <p> Updated patch with better one, fixed a bug with conversions of signed integers to unsigned integers </p> Ticket Antony Polukhin Thu, 27 Dec 2012 20:17:11 GMT <link>https://svn.boost.org/trac10/ticket/7814#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:8</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/82227" title="More strict tests, less workarounds, bugfixes (refs #7814)">[82227]</a>) More strict tests, less workarounds, bugfixes (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7814" title="#7814: Bugs: Signal 6 coredump on lexical_cast with gcc option trapv (closed: fixed)">#7814</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 29 Dec 2012 14:43:59 GMT</pubDate> <title>status changed; resolution, milestone set https://svn.boost.org/trac10/ticket/7814#comment:9 https://svn.boost.org/trac10/ticket/7814#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> → <span class="trac-field-new">Boost 1.53.0</span> </li> </ul> <p> Fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/82268" title="Merge from trunk: fixes #7814 (fixed some numeric to numeric ...">[82268]</a> </p> Ticket Antony Polukhin Sun, 03 Feb 2013 07:39:00 GMT <link>https://svn.boost.org/trac10/ticket/7814#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7814#comment:10</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/82694" title="More tests (refs #7814)">[82694]</a>) More tests (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7814" title="#7814: Bugs: Signal 6 coredump on lexical_cast with gcc option trapv (closed: fixed)">#7814</a>) </p> </description> <category>Ticket</category> </item> </channel> </rss>