Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On 01/19/2013 03:12 PM, Michael Stahl wrote:
On 19/01/13 11:28, Lubos Lunak wrote:
  -Wsign-promo is a rather pointless warning these days (the section in the gcc
manpage is a funny read and not only because it talks about Cfront). I've

Some of the funniness is likely due to <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56067> "Removal of -Wsynth from doc didn't remove example."

added more overloads to silence it, but I rather wonder why we have this
explicitly enabled at all.

  My hypothesis is like this:
- the idea behind the warning is just nonsense (who cares to what integer type
the value is promoted)

overflow for unsigned integral types is defined by the C and C++
standards, while overflow for signed types is explicitly undefined.
some implementations therefore assume that it does not occur and may
remove tests on signed integers from the code that could only evaluate
to true in case of an overflow in order to improve the all-important
SPEC benchmark scores.

-Wsign-promo is specifically about overload resolution, i'm not sure if
that overflow problem would be relevant in this case but this is C++ so
i'm never sure about anything :)

No, undefined behavior due to signed overflow is not relevant here. For the integral promotion involved in overload resolution, no overflow can happen. (And the overflow that can happen with integral conversion, say a truncation from long to int, is implementation-defined rather than undefined, btw.)

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.