doc: Note that some warnings depend on optimizations (PR 92757)

Message ID 20191202213501.GA1034837@redhat.com
State New
Headers show
Series
  • doc: Note that some warnings depend on optimizations (PR 92757)
Related show

Commit Message

Jonathan Wakely Dec. 2, 2019, 9:35 p.m.
PR driver/92757
	* doc/invoke.texi (Warning Options): Add caveat about some warnings
	depending on optimization settings.

The bug reporter wants this clarified. I'm not entirely convinced it's
necessary, but it doesn't seem to do any harm.

OK for trunk?
commit 5e0f6aebde20712f318d3bcfcd25809e04be4460
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Dec 2 21:32:54 2019 +0000

    doc: Note that some warnings depend on optimizations (PR 92757)
    
            PR driver/92757
            * doc/invoke.texi (Warning Options): Add caveat about some warnings
            depending on optimization settings.

Comments

Gerald Pfeifer Jan. 12, 2020, 8:02 p.m. | #1
On Mon, 2 Dec 2019, Jonathan Wakely wrote:
> 	PR driver/92757

> 	* doc/invoke.texi (Warning Options): Add caveat about some warnings

> 	depending on optimization settings.

> 

> The bug reporter wants this clarified. I'm not entirely convinced it's

> necessary, but it doesn't seem to do any harm.

> 

> OK for trunk?


Yes, thank you.

(I can see how this can help, and even if it only helps one in twenty
users, say, that's still worthwhile.)

Gerald
Martin Sebor Jan. 13, 2020, 5:27 p.m. | #2
On 12/2/19 9:35 PM, Jonathan Wakely wrote:
>      PR driver/92757

>      * doc/invoke.texi (Warning Options): Add caveat about some warnings

>      depending on optimization settings.

> 

> The bug reporter wants this clarified. I'm not entirely convinced it's

> necessary, but it doesn't seem to do any harm.

> 

> OK for trunk?


I think adding something to the manual about this interplay would
be useful but I'm not sure that saying only that some warnings have
this dependency will help all that much.  I think each warning that
significantly depends on optimization should document it and,
ideally, explain to what extent.  That way users will be clear on
what to expect.  I suspect I might have been responsible for at least
some of the confusion here (I've added warnings that work both with
and without optimization but that do a much better job with it than
without), so I should probably take an AI to review the manual and
try to add some clarity.

Martin
Jonathan Wakely Jan. 13, 2020, 6:46 p.m. | #3
On 13/01/20 17:27 +0000, Martin Sebor wrote:
>On 12/2/19 9:35 PM, Jonathan Wakely wrote:

>>     PR driver/92757

>>     * doc/invoke.texi (Warning Options): Add caveat about some warnings

>>     depending on optimization settings.

>>

>>The bug reporter wants this clarified. I'm not entirely convinced it's

>>necessary, but it doesn't seem to do any harm.

>>

>>OK for trunk?

>

>I think adding something to the manual about this interplay would

>be useful but I'm not sure that saying only that some warnings have

>this dependency will help all that much.  I think each warning that

>significantly depends on optimization should document it and,

>ideally, explain to what extent.  That way users will be clear on

>what to expect.  I suspect I might have been responsible for at least

>some of the confusion here (I've added warnings that work both with

>and without optimization but that do a much better job with it than

>without), so I should probably take an AI to review the manual and

>try to add some clarity.


Some of them already do say it, the bug report was that users
shouldn't have to read every individual option to learn that
diagnostic quality varies with optimisations.

Patch

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d165f31a865..099faf5f662 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4361,6 +4361,11 @@  are being produced.  This allows the use of new @option{-Wno-} options
 with old compilers, but if something goes wrong, the compiler
 warns that an unrecognized option is present.
 
+The effectiveness of some warnings depends on optimizations also being
+enabled. For example @option{-Wsuggest-final-types} is more effective
+with link-time optimization and @option{-Wmaybe-uninitialized} will not
+warn at all unless optimization is enabled.
+
 @table @gcctabopt
 @item -Wpedantic
 @itemx -pedantic