[wwwdocs] List -Wabsolute-value in gcc-9/changes.html

Martin Sebor msebor@gmail.com
Mon Jan 28 19:02:00 GMT 2019


On 1/26/19 3:37 PM, Martin Jambor wrote:
> Hi,
> 
> On Sat, Jan 26 2019, Gerald Pfeifer wrote:
>> On Sat, 26 Jan 2019, Martin Jambor wrote:
>>> I'd like to propose the following hunk mentioning -Wabsolute-value in
>>> changes.html of the upcoming gcc 9.  Is it OK?
>>
>> Lovely^WThanks, ok!
>>
>> Actually, one question:
>>
>>> +      <li><code>-Wabsolute-value</code> warns when a wrong absolute value
>>> +       function seems to be used or when it does not have any effect because
>>> +       its argument is an unsigned type.  The <code>-Wabsolute-value</code>
>>> +       option is included in <code>-Wextra</code>.
>>
>> What is a "wrong absolute value function"?  That might be good to
>> show by means of an example?  (Also in invoke.texi, which I checked
>> before writing this.)
> 
> Most usually wrong means an absolute value function for a shorter type
> than the one privided, such as abs when labs would be approproiate, or
> abs or labs when you actually need llabs.  Or using normal
> floating-point absolute value function such as fabs for
> binary-coded-decimal.  Or even for a complex double/float, which
> hitherto passed without a warning.
> 
> I'm not sure how to change the wording, perhaps "...when a used absolute
> value function seems wrong for the type of its argument" ...?

Would this work?

   -Wabsolute-value warns for calls to standard functions that compute
   the absolute value of an argument when a more appropriate standard
   function is available.  For example, calling abs(3.14) triggers
   the warning because the appropriate function to call to compute
   the absolute value of a double argument is fabs.  The option also
   triggers warnings when the argument in a call to such a function
   has an unsigned type.

Martin



More information about the Gcc-patches mailing list