-Wsign-promo (Re: [BUILD FAILS DEBUG MODE] with test_strings_valuex.cxx)

Michael Stahl mstahl at redhat.com
Sat Jan 19 06:12:43 PST 2013


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 
> 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 :)

> - but it incidentally triggers when passing bool to SvStream, because it 
> doesn't have any overload for operator<<(bool), and int is chosen over 
> unsigned char AKA sal_Bool , so Caolan added it in 
> e8bbb76827dd7a0e30d7d1db34a812a84d85f390
> - if SvStream gets overload for bool, the warning can be dumped
> 
>  Or am I missing something there?

maybe there are more overloaded identifiers that simply haven't been
called with wrongly promoted parameters yet?




More information about the LibreOffice mailing list