diff mbox series

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

Message ID ri636pft6yb.fsf@suse.cz
State New
Headers show
Series [wwwdocs] List -Wabsolute-value in gcc-9/changes.html | expand

Commit Message

Martin Jambor Jan. 26, 2019, 10 p.m. UTC
Hi,

I'd like to propose the following hunk mentioning -Wabsolute-value in
changes.html of the upcoming gcc 9.  Is it OK?

Thanks,

Martin

Comments

Gerald Pfeifer Jan. 26, 2019, 10:19 p.m. UTC | #1
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.)

Gerald
Martin Jambor Jan. 26, 2019, 10:37 p.m. UTC | #2
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" ...?

Martin
Martin Sebor Jan. 28, 2019, 6:51 p.m. UTC | #3
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
Gerald Pfeifer Jan. 28, 2019, 7:02 p.m. UTC | #4
Hi Martin,

On Sat, 26 Jan 2019, Martin Jambor wrote:
>> 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.)
> I'm not sure how to change the wording, perhaps "...when a used absolute
> value function seems wrong for the type of its argument" ...?

yes, that definitely would have helped me as a user.  (I guessed
it might be that, but seeing it in writing helps.)

On Mon, 28 Jan 2019, Martin Sebor wrote:
>   -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.

Lovely.  

(I'd say "This option...", but that's probably a matter of taste.)

Are you going to enhance both invoke.texi and apply a patch to the
release notes (changes.html)?  That would be ideal.

Thanks!

Gerald
Martin Jambor Feb. 13, 2019, 5:42 p.m. UTC | #5
Hi Gerald and Martin,

On Mon, Jan 28 2019, Gerald Pfeifer wrote:
> Hi Martin,
>
> On Sat, 26 Jan 2019, Martin Jambor wrote:
>>> 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.)
>> I'm not sure how to change the wording, perhaps "...when a used absolute
>> value function seems wrong for the type of its argument" ...?
>
> yes, that definitely would have helped me as a user.  (I guessed
> it might be that, but seeing it in writing helps.)
>
> On Mon, 28 Jan 2019, Martin Sebor wrote:
>>   -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.
>
> Lovely.  
>
> (I'd say "This option...", but that's probably a matter of taste.)
>
> Are you going to enhance both invoke.texi and apply a patch to the
> release notes (changes.html)?  That would be ideal.
>

I have incorporated Martin's extended description to both invoke.texi
and changes.html, the result is in the two patches below.  OK to commit
to trunk and to wwwdocs CVS repo respectively?

Thanks,

Martin


diff -u -r1.38 changes.html
--- htdocs/gcc-9/changes.html   7 Feb 2019 11:49:26 -0000       1.38
+++ htdocs/gcc-9/changes.html   13 Feb 2019 17:38:57 -0000
@@ -89,6 +89,23 @@
   </ul></li>
 </ul>
 
+<h3 id="c">C</h3>
+<ul>
+  <li>New warnings:
+  <ul>
+    <li><code>-Wabsolute-value</code> 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 <code>abs(3.14)</code> triggers the warning because the
+      appropriate function to call to compute the absolute value of a
+      double argument is <code>fabs</code>.  The option also triggers
+      warnings when the argument in a call to such a function has an
+      unsigned type.  This warning can be suppressed with an explicit
+      type cast and it is also enabled by <code>-Wextra</code>.
+    </li>
+  </ul></li>
+</ul>
+
 <h3 id="cxx">C++</h3>
 <ul>
   <li>New warnings:



2019-02-13  Martin Jambor  <mjambor@suse.cz>
	    Martin Sebor  <msebor@redhat.com>

	* doc/invoke.texi (Warning Options): Reword description of
	-Wno-absolute-value.
---
 gcc/doc/invoke.texi | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c625350d04d..a8bafbebce8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -6633,9 +6633,13 @@ example, warn if an unsigned variable is compared against zero with
 @item -Wabsolute-value @r{(C and Objective-C only)}
 @opindex Wabsolute-value
 @opindex Wno-absolute-value
-Warn 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.
-This warning be suppressed with an explicit type cast and it is also
+Warn for calls to standard functions that compute the absolute value
+of an argument when a more appropriate standard function is available.
+For example, calling @code{abs(3.14)} triggers the warning because the
+appropriate function to call to compute the absolute value of a double
+argument is @code{fabs}.  The option also triggers warnings when the
+argument in a call to such a function has an unsigned type.  This
+warning can be suppressed with an explicit type cast and it is also
 enabled by @option{-Wextra}.
 
 @include cppwarnopts.texi
Martin Jambor Feb. 26, 2019, 1:25 p.m. UTC | #6
Hi,

On Wed, Feb 13 2019, Martin Jambor wrote:
> Hi Gerald and Martin,
>
> On Mon, Jan 28 2019, Gerald Pfeifer wrote:
>> Hi Martin,
>>
>> On Sat, 26 Jan 2019, Martin Jambor wrote:
>>>> 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.)
>>> I'm not sure how to change the wording, perhaps "...when a used absolute
>>> value function seems wrong for the type of its argument" ...?
>>
>> yes, that definitely would have helped me as a user.  (I guessed
>> it might be that, but seeing it in writing helps.)
>>
>> On Mon, 28 Jan 2019, Martin Sebor wrote:
>>>   -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.
>>
>> Lovely.  
>>
>> (I'd say "This option...", but that's probably a matter of taste.)
>>
>> Are you going to enhance both invoke.texi and apply a patch to the
>> release notes (changes.html)?  That would be ideal.
>>
>
> I have incorporated Martin's extended description to both invoke.texi
> and changes.html, the result is in the two patches below.  OK to commit
> to trunk and to wwwdocs CVS repo respectively?

Since it is documentation only and because the change was basically
pre-approved by Gerald, I plan to commit both later today (unless
someone stops me).  I hope I'm not stretching the rules too much.

Martin

>
>
> diff -u -r1.38 changes.html
> --- htdocs/gcc-9/changes.html   7 Feb 2019 11:49:26 -0000       1.38
> +++ htdocs/gcc-9/changes.html   13 Feb 2019 17:38:57 -0000
> @@ -89,6 +89,23 @@
>    </ul></li>
>  </ul>
>  
> +<h3 id="c">C</h3>
> +<ul>
> +  <li>New warnings:
> +  <ul>
> +    <li><code>-Wabsolute-value</code> 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 <code>abs(3.14)</code> triggers the warning because the
> +      appropriate function to call to compute the absolute value of a
> +      double argument is <code>fabs</code>.  The option also triggers
> +      warnings when the argument in a call to such a function has an
> +      unsigned type.  This warning can be suppressed with an explicit
> +      type cast and it is also enabled by <code>-Wextra</code>.
> +    </li>
> +  </ul></li>
> +</ul>
> +
>  <h3 id="cxx">C++</h3>
>  <ul>
>    <li>New warnings:
>
>
>
> 2019-02-13  Martin Jambor  <mjambor@suse.cz>
> 	    Martin Sebor  <msebor@redhat.com>
>
> 	* doc/invoke.texi (Warning Options): Reword description of
> 	-Wno-absolute-value.
> ---
>  gcc/doc/invoke.texi | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index c625350d04d..a8bafbebce8 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -6633,9 +6633,13 @@ example, warn if an unsigned variable is compared against zero with
>  @item -Wabsolute-value @r{(C and Objective-C only)}
>  @opindex Wabsolute-value
>  @opindex Wno-absolute-value
> -Warn 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.
> -This warning be suppressed with an explicit type cast and it is also
> +Warn for calls to standard functions that compute the absolute value
> +of an argument when a more appropriate standard function is available.
> +For example, calling @code{abs(3.14)} triggers the warning because the
> +appropriate function to call to compute the absolute value of a double
> +argument is @code{fabs}.  The option also triggers warnings when the
> +argument in a call to such a function has an unsigned type.  This
> +warning can be suppressed with an explicit type cast and it is also
>  enabled by @option{-Wextra}.
>  
>  @include cppwarnopts.texi
> -- 
> 2.20.1
diff mbox series

Patch

Index: htdocs/gcc-9/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-9/changes.html,v
retrieving revision 1.36
diff -u -r1.36 changes.html
--- htdocs/gcc-9/changes.html   18 Jan 2019 11:52:13 -0000      1.36
+++ htdocs/gcc-9/changes.html   26 Jan 2019 21:57:17 -0000
@@ -89,6 +89,18 @@ 
   </ul></li>
 </ul>
 
+<h3 id="c">C</h3>
+<ul>
+  <li>New warnings:
+  <ul>
+      <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>.
+      </li>
+  </ul></li>
+</ul>
+
 <h3 id="cxx">C++</h3>
 <ul>
   <li>New warnings: