public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Clarify interaction of -Wnarrowing with -std
@ 2016-02-19 12:42 Jonathan Wakely
  2016-02-19 19:01 ` Jason Merrill
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2016-02-19 12:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill, Gerald Pfeifer, Sandra Loosemore, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

In PR69864 Manu suggests improving the docs to explain that
-Wnarrowing sometimes produces errors not warnings.

I think the right way to do that is clarify how it interacts with
-std. Specifically that the effect of -Wnarrowing listed first in the
manual *only* applies to C++98 modes, For all later modes (not just
with -std=c++11 as it says now), narrowing conversions produce errors
or warnings by default.

OK for trunk?



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1720 bytes --]

commit b78b2728d8d946bd92843f6155cdd2415682da09
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Feb 19 12:14:33 2016 +0000

    	* doc/invoke.texi (C++ Dialect Options): Clarify interaction of
    	-Wnarrowing with -std.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2bd793d..c1ab788 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2756,7 +2756,8 @@ Requires @option{-flto} to be enabled.  Enabled by default.
 @item -Wnarrowing @r{(C++ and Objective-C++ only)}
 @opindex Wnarrowing
 @opindex Wno-narrowing
-Warn when a narrowing conversion prohibited by C++11 occurs within
+With @option{-std=gnu++98} or @option{-std=c++98}, warn when a narrowing
+conversion prohibited by C++11 occurs within
 @samp{@{ @}}, e.g.
 
 @smallexample
@@ -2765,10 +2766,13 @@ int i = @{ 2.2 @}; // error: narrowing from double to int
 
 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
 
-With @option{-std=c++11}, @option{-Wno-narrowing} suppresses the diagnostic
-required by the standard.  Note that this does not affect the meaning
-of well-formed code; narrowing conversions are still considered
-ill-formed in SFINAE context.
+When a later standard is in effect, e.g. when using @option{-std=c++11},
+narrowing conversions are diagnosed by default, as required by the standard.
+A narrowing conversion from a constant produces an error,
+and a narrowing conversion from a non-constant produces a warning,
+but @option{-Wno-narrowing} suppresses the diagnostic.
+Note that this does not affect the meaning of well-formed code;
+narrowing conversions are still considered ill-formed in SFINAE contexts.
 
 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
 @opindex Wnoexcept

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2016-02-19 12:42 [patch] Clarify interaction of -Wnarrowing with -std Jonathan Wakely
@ 2016-02-19 19:01 ` Jason Merrill
  2016-02-19 20:17   ` Sandra Loosemore
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Merrill @ 2016-02-19 19:01 UTC (permalink / raw)
  To: Jonathan Wakely, gcc-patches
  Cc: Gerald Pfeifer, Sandra Loosemore, Joseph Myers

On 02/19/2016 07:42 AM, Jonathan Wakely wrote:
> In PR69864 Manu suggests improving the docs to explain that
> -Wnarrowing sometimes produces errors not warnings.
>
> I think the right way to do that is clarify how it interacts with
> -std. Specifically that the effect of -Wnarrowing listed first in the
> manual *only* applies to C++98 modes, For all later modes (not just
> with -std=c++11 as it says now), narrowing conversions produce errors
> or warnings by default.
>
> OK for trunk?

OK, thanks.

Jason


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2016-02-19 19:01 ` Jason Merrill
@ 2016-02-19 20:17   ` Sandra Loosemore
  2016-02-19 20:33     ` Jonathan Wakely
  2016-02-23 18:39     ` Jonathan Wakely
  0 siblings, 2 replies; 9+ messages in thread
From: Sandra Loosemore @ 2016-02-19 20:17 UTC (permalink / raw)
  To: Jason Merrill, Jonathan Wakely, gcc-patches; +Cc: Gerald Pfeifer, Joseph Myers

On 02/19/2016 12:01 PM, Jason Merrill wrote:
> On 02/19/2016 07:42 AM, Jonathan Wakely wrote:
>> In PR69864 Manu suggests improving the docs to explain that
>> -Wnarrowing sometimes produces errors not warnings.
>>
>> I think the right way to do that is clarify how it interacts with
>> -std. Specifically that the effect of -Wnarrowing listed first in the
>> manual *only* applies to C++98 modes, For all later modes (not just
>> with -std=c++11 as it says now), narrowing conversions produce errors
>> or warnings by default.
>>
>> OK for trunk?
>
> OK, thanks.

I suppose the patch is OK as it stands, but I was going to suggest 
restructuring it so that it talks about the default behavior first and 
what it does with non-default -std= options after that, instead of 
vice-versa.  Unfortunately I am backlogged on other things right now and 
it might take me a day or two before I have time to come up with some 
alternate wording.  If we are in a rush, go ahead and commit the 
existing patch meanwhile, I guess.

-Sandra

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2016-02-19 20:17   ` Sandra Loosemore
@ 2016-02-19 20:33     ` Jonathan Wakely
  2016-02-23 18:39     ` Jonathan Wakely
  1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Wakely @ 2016-02-19 20:33 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Jason Merrill, gcc-patches, Gerald Pfeifer, Joseph Myers

On 19/02/16 13:17 -0700, Sandra Loosemore wrote:
>On 02/19/2016 12:01 PM, Jason Merrill wrote:
>>On 02/19/2016 07:42 AM, Jonathan Wakely wrote:
>>>In PR69864 Manu suggests improving the docs to explain that
>>>-Wnarrowing sometimes produces errors not warnings.
>>>
>>>I think the right way to do that is clarify how it interacts with
>>>-std. Specifically that the effect of -Wnarrowing listed first in the
>>>manual *only* applies to C++98 modes, For all later modes (not just
>>>with -std=c++11 as it says now), narrowing conversions produce errors
>>>or warnings by default.
>>>
>>>OK for trunk?
>>
>>OK, thanks.
>
>I suppose the patch is OK as it stands, but I was going to suggest 
>restructuring it so that it talks about the default behavior first and 
>what it does with non-default -std= options after that, instead of 
>vice-versa.  Unfortunately I am backlogged on other things right now 
>and it might take me a day or two before I have time to come up with 
>some alternate wording.  If we are in a rush, go ahead and commit the 
>existing patch meanwhile, I guess.

I did wonder about that but couldn't come up with wording I liked.

I went ahead and committed it after Jason's OK, but I can take another
look at it next week.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2016-02-19 20:17   ` Sandra Loosemore
  2016-02-19 20:33     ` Jonathan Wakely
@ 2016-02-23 18:39     ` Jonathan Wakely
  2017-03-26 20:32       ` Gerald Pfeifer
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2016-02-23 18:39 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Jason Merrill, gcc-patches, Gerald Pfeifer, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]

On 19/02/16 13:17 -0700, Sandra Loosemore wrote:
>On 02/19/2016 12:01 PM, Jason Merrill wrote:
>>On 02/19/2016 07:42 AM, Jonathan Wakely wrote:
>>>In PR69864 Manu suggests improving the docs to explain that
>>>-Wnarrowing sometimes produces errors not warnings.
>>>
>>>I think the right way to do that is clarify how it interacts with
>>>-std. Specifically that the effect of -Wnarrowing listed first in the
>>>manual *only* applies to C++98 modes, For all later modes (not just
>>>with -std=c++11 as it says now), narrowing conversions produce errors
>>>or warnings by default.
>>>
>>>OK for trunk?
>>
>>OK, thanks.
>
>I suppose the patch is OK as it stands, but I was going to suggest 
>restructuring it so that it talks about the default behavior first and 
>what it does with non-default -std= options after that, instead of 
>vice-versa.  Unfortunately I am backlogged on other things right now 
>and it might take me a day or two before I have time to come up with 
>some alternate wording.  If we are in a rush, go ahead and commit the 
>existing patch meanwhile, I guess.

Is this better?



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1857 bytes --]

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 490df93..8d56efa 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2753,10 +2753,17 @@ During the link-time optimization warn about type mismatches in
 global declarations from different compilation units.
 Requires @option{-flto} to be enabled.  Enabled by default.
 
-@item -Wnarrowing @r{(C++ and Objective-C++ only)}
+@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
 @opindex Wnarrowing
 @opindex Wno-narrowing
-With @option{-std=gnu++98} or @option{-std=c++98}, warn when a narrowing
+For C++11 and later standards, narrowing conversions are diagnosed by default,
+as required by the standard.  A narrowing conversion from a constant produces
+an error, and a narrowing conversion from a non-constant produces a warning,
+but @option{-Wno-narrowing} suppresses the diagnostic.
+Note that this does not affect the meaning of well-formed code;
+narrowing conversions are still considered ill-formed in SFINAE contexts.
+
+With @option{-Wnarrowing} in C++98, warn when a narrowing
 conversion prohibited by C++11 occurs within
 @samp{@{ @}}, e.g.
 
@@ -2766,14 +2773,6 @@ int i = @{ 2.2 @}; // error: narrowing from double to int
 
 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
 
-When a later standard is in effect, e.g. when using @option{-std=c++11},
-narrowing conversions are diagnosed by default, as required by the standard.
-A narrowing conversion from a constant produces an error,
-and a narrowing conversion from a non-constant produces a warning,
-but @option{-Wno-narrowing} suppresses the diagnostic.
-Note that this does not affect the meaning of well-formed code;
-narrowing conversions are still considered ill-formed in SFINAE contexts.
-
 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
 @opindex Wnoexcept
 @opindex Wno-noexcept

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2016-02-23 18:39     ` Jonathan Wakely
@ 2017-03-26 20:32       ` Gerald Pfeifer
  2017-03-26 21:00         ` Sandra Loosemore
  0 siblings, 1 reply; 9+ messages in thread
From: Gerald Pfeifer @ 2017-03-26 20:32 UTC (permalink / raw)
  To: Jonathan Wakely, Sandra Loosemore
  Cc: Jason Merrill, gcc-patches, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 820 bytes --]

Hi Jonathan,

On Tue, 23 Feb 2016, Jonathan Wakely wrote:
> On 19/02/16 13:17 -0700, Sandra Loosemore wrote:
>> I suppose the patch is OK as it stands, but I was going to suggest
>> restructuring it so that it talks about the default behavior first and what
>> it does with non-default -std= options after that, instead of vice-versa.
>> Unfortunately I am backlogged on other things right now and it might take me
>> a day or two before I have time to come up with some alternate wording.  If
>> we are in a rush, go ahead and commit the existing patch meanwhile, I guess.
> Is this better?

I believe your follow-up patch did not get committed, nor did I
see any response from anyone.

To me it looks fine.  Did you hold of intentionally, or did this
get lost for lack of responses?

Sandra, what do you think?

Gerald

[-- Attachment #2: Type: text/x-patch, Size: 1857 bytes --]

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 490df93..8d56efa 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2753,10 +2753,17 @@ During the link-time optimization warn about type mismatches in
 global declarations from different compilation units.
 Requires @option{-flto} to be enabled.  Enabled by default.
 
-@item -Wnarrowing @r{(C++ and Objective-C++ only)}
+@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
 @opindex Wnarrowing
 @opindex Wno-narrowing
-With @option{-std=gnu++98} or @option{-std=c++98}, warn when a narrowing
+For C++11 and later standards, narrowing conversions are diagnosed by default,
+as required by the standard.  A narrowing conversion from a constant produces
+an error, and a narrowing conversion from a non-constant produces a warning,
+but @option{-Wno-narrowing} suppresses the diagnostic.
+Note that this does not affect the meaning of well-formed code;
+narrowing conversions are still considered ill-formed in SFINAE contexts.
+
+With @option{-Wnarrowing} in C++98, warn when a narrowing
 conversion prohibited by C++11 occurs within
 @samp{@{ @}}, e.g.
 
@@ -2766,14 +2773,6 @@ int i = @{ 2.2 @}; // error: narrowing from double to int
 
 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
 
-When a later standard is in effect, e.g. when using @option{-std=c++11},
-narrowing conversions are diagnosed by default, as required by the standard.
-A narrowing conversion from a constant produces an error,
-and a narrowing conversion from a non-constant produces a warning,
-but @option{-Wno-narrowing} suppresses the diagnostic.
-Note that this does not affect the meaning of well-formed code;
-narrowing conversions are still considered ill-formed in SFINAE contexts.
-
 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
 @opindex Wnoexcept
 @opindex Wno-noexcept

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2017-03-26 20:32       ` Gerald Pfeifer
@ 2017-03-26 21:00         ` Sandra Loosemore
  2017-03-27  9:10           ` Jonathan Wakely
  0 siblings, 1 reply; 9+ messages in thread
From: Sandra Loosemore @ 2017-03-26 21:00 UTC (permalink / raw)
  To: Gerald Pfeifer, Jonathan Wakely; +Cc: Jason Merrill, gcc-patches, Joseph Myers

On 03/26/2017 02:13 PM, Gerald Pfeifer wrote:
> Hi Jonathan,
>
> On Tue, 23 Feb 2016, Jonathan Wakely wrote:
>> On 19/02/16 13:17 -0700, Sandra Loosemore wrote:
>>> I suppose the patch is OK as it stands, but I was going to suggest
>>> restructuring it so that it talks about the default behavior first
>>> and what
>>> it does with non-default -std= options after that, instead of
>>> vice-versa.
>>> Unfortunately I am backlogged on other things right now and it might
>>> take me
>>> a day or two before I have time to come up with some alternate
>>> wording.  If
>>> we are in a rush, go ahead and commit the existing patch meanwhile, I
>>> guess.
>> Is this better?
>
> I believe your follow-up patch did not get committed, nor did I
> see any response from anyone.
>
> To me it looks fine.  Did you hold of intentionally, or did this
> get lost for lack of responses?
>
> Sandra, what do you think?

Looks OK to me.  I apologize for losing track of this patch previously.  :-(

-Sandra

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2017-03-26 21:00         ` Sandra Loosemore
@ 2017-03-27  9:10           ` Jonathan Wakely
  2017-03-28  3:25             ` Jonathan Wakely
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2017-03-27  9:10 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Gerald Pfeifer, Jason Merrill, gcc-patches, Joseph Myers

On 26/03/17 14:32 -0600, Sandra Loosemore wrote:
>On 03/26/2017 02:13 PM, Gerald Pfeifer wrote:
>>Hi Jonathan,
>>
>>On Tue, 23 Feb 2016, Jonathan Wakely wrote:
>>>On 19/02/16 13:17 -0700, Sandra Loosemore wrote:
>>>>I suppose the patch is OK as it stands, but I was going to suggest
>>>>restructuring it so that it talks about the default behavior first
>>>>and what
>>>>it does with non-default -std= options after that, instead of
>>>>vice-versa.
>>>>Unfortunately I am backlogged on other things right now and it might
>>>>take me
>>>>a day or two before I have time to come up with some alternate
>>>>wording.  If
>>>>we are in a rush, go ahead and commit the existing patch meanwhile, I
>>>>guess.
>>>Is this better?
>>
>>I believe your follow-up patch did not get committed, nor did I
>>see any response from anyone.
>>
>>To me it looks fine.  Did you hold of intentionally, or did this
>>get lost for lack of responses?
>>
>>Sandra, what do you think?
>
>Looks OK to me.  I apologize for losing track of this patch previously.  :-(

OK, thanks, I'll commit it today.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Clarify interaction of -Wnarrowing with -std
  2017-03-27  9:10           ` Jonathan Wakely
@ 2017-03-28  3:25             ` Jonathan Wakely
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Wakely @ 2017-03-28  3:25 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: Gerald Pfeifer, Jason Merrill, gcc-patches, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]

On 27/03/17 10:09 +0100, Jonathan Wakely wrote:
>On 26/03/17 14:32 -0600, Sandra Loosemore wrote:
>>On 03/26/2017 02:13 PM, Gerald Pfeifer wrote:
>>>Hi Jonathan,
>>>
>>>On Tue, 23 Feb 2016, Jonathan Wakely wrote:
>>>>On 19/02/16 13:17 -0700, Sandra Loosemore wrote:
>>>>>I suppose the patch is OK as it stands, but I was going to suggest
>>>>>restructuring it so that it talks about the default behavior first
>>>>>and what
>>>>>it does with non-default -std= options after that, instead of
>>>>>vice-versa.
>>>>>Unfortunately I am backlogged on other things right now and it might
>>>>>take me
>>>>>a day or two before I have time to come up with some alternate
>>>>>wording.  If
>>>>>we are in a rush, go ahead and commit the existing patch meanwhile, I
>>>>>guess.
>>>>Is this better?
>>>
>>>I believe your follow-up patch did not get committed, nor did I
>>>see any response from anyone.
>>>
>>>To me it looks fine.  Did you hold of intentionally, or did this
>>>get lost for lack of responses?
>>>
>>>Sandra, what do you think?
>>
>>Looks OK to me.  I apologize for losing track of this patch previously.  :-(
>
>OK, thanks, I'll commit it today.

I've committed the attached patch.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2133 bytes --]

commit 77d4b96ba46e57a761e6844b89de9412011ef583
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Mar 27 19:37:01 2017 +0100

    Restructure -Wno-narrowing documentation
    
    	* doc/invoke.texi (-Wno-narrowing): Reorder so default behavior is
    	covered first.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 3f0eb2f..8d3821e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2869,10 +2869,17 @@ During the link-time optimization warn about type mismatches in
 global declarations from different compilation units.
 Requires @option{-flto} to be enabled.  Enabled by default.
 
-@item -Wnarrowing @r{(C++ and Objective-C++ only)}
+@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
 @opindex Wnarrowing
 @opindex Wno-narrowing
-With @option{-std=gnu++98} or @option{-std=c++98}, warn when a narrowing
+For C++11 and later standards, narrowing conversions are diagnosed by default,
+as required by the standard.  A narrowing conversion from a constant produces
+an error, and a narrowing conversion from a non-constant produces a warning,
+but @option{-Wno-narrowing} suppresses the diagnostic.
+Note that this does not affect the meaning of well-formed code;
+narrowing conversions are still considered ill-formed in SFINAE contexts.
+
+With @option{-Wnarrowing} in C++98, warn when a narrowing
 conversion prohibited by C++11 occurs within
 @samp{@{ @}}, e.g.
 
@@ -2882,14 +2889,6 @@ int i = @{ 2.2 @}; // error: narrowing from double to int
 
 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
 
-When a later standard is in effect, e.g. when using @option{-std=c++11},
-narrowing conversions are diagnosed by default, as required by the standard.
-A narrowing conversion from a constant produces an error,
-and a narrowing conversion from a non-constant produces a warning,
-but @option{-Wno-narrowing} suppresses the diagnostic.
-Note that this does not affect the meaning of well-formed code;
-narrowing conversions are still considered ill-formed in SFINAE contexts.
-
 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
 @opindex Wnoexcept
 @opindex Wno-noexcept

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-27 22:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 12:42 [patch] Clarify interaction of -Wnarrowing with -std Jonathan Wakely
2016-02-19 19:01 ` Jason Merrill
2016-02-19 20:17   ` Sandra Loosemore
2016-02-19 20:33     ` Jonathan Wakely
2016-02-23 18:39     ` Jonathan Wakely
2017-03-26 20:32       ` Gerald Pfeifer
2017-03-26 21:00         ` Sandra Loosemore
2017-03-27  9:10           ` Jonathan Wakely
2017-03-28  3:25             ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).