[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2021-09-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

Andrew Pinski  changed:

   What|Removed |Added

 CC||antoshkka at gmail dot com

--- Comment #16 from Andrew Pinski  ---
*** Bug 96452 has been marked as a duplicate of this bug. ***

[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2019-12-09 Thread marc at kdab dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

Marc Mutz  changed:

   What|Removed |Added

 CC||marc at kdab dot com

--- Comment #15 from Marc Mutz  ---
*** Bug 92856 has been marked as a duplicate of this bug. ***

[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2016-07-24 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

--- Comment #14 from Manuel López-Ibáñez  ---
*** Bug 71985 has been marked as a duplicate of this bug. ***

[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2016-07-24 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

Markus Trippelsdorf  changed:

   What|Removed |Added

 CC||nico at josuttis dot de

--- Comment #13 from Markus Trippelsdorf  ---
*** Bug 71985 has been marked as a duplicate of this bug. ***

[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2016-02-18 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

Manuel López-Ibáñez  changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #12 from Manuel López-Ibáñez  ---
Since it seems this has to be explained repeatedly (and I had to read this in
detail to understand why this is a pedwarn enabled by -Wall), I created a FAQ:
https://gcc.gnu.org/wiki/FAQ#Wnarrowing

Jonathan, I used most of your comment #4 verbatim, I hope this is OK. Feel free
to edit it for corrections or further clarification.

[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2016-02-18 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

Manuel López-Ibáñez  changed:

   What|Removed |Added

 CC||mgsergio at yandex dot ru

--- Comment #11 from Manuel López-Ibáñez  ---
*** Bug 69864 has been marked as a duplicate of this bug. ***

[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2013-11-04 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||thomas.braun@virtuell-zuhau
   ||se.de

--- Comment #10 from Paolo Carlini paolo.carlini at oracle dot com ---
*** Bug 58986 has been marked as a duplicate of this bug. ***


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2013-02-15 Thread jason at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



Jason Merrill jason at gcc dot gnu.org changed:



   What|Removed |Added



 Status|UNCONFIRMED |RESOLVED

 CC||jason at gcc dot gnu.org

 Resolution||WORKSFORME



--- Comment #9 from Jason Merrill jason at gcc dot gnu.org 2013-02-15 
17:16:39 UTC ---

You can use -pedantic-errors to turn this and various other violations from

warnings into errors.


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread pinskia at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



--- Comment #1 from Andrew Pinski pinskia at gcc dot gnu.org 2012-12-22 
00:06:50 UTC ---

With -std=c++11, -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. 


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread david at stellarscience dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



--- Comment #2 from David Sankel david at stellarscience dot com 2012-12-22 
00:13:33 UTC ---

From what I understand, the standard requires the compiler to reject the

program, not to accept it with a warning.


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread pinskia at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



--- Comment #3 from Andrew Pinski pinskia at gcc dot gnu.org 2012-12-22 
00:15:04 UTC ---

use -Werror=Wnarrowing then


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread redi at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



Jonathan Wakely redi at gcc dot gnu.org changed:



   What|Removed |Added



   Severity|major   |normal



--- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org 2012-12-22 
00:26:10 UTC ---

The standard only requires that a conforming implementation shall issue at

least one diagnostic message so compiling the program with a warning is

allowed.  As Andrew said, -Werror=narrowing allows you to make it an error if

you want.



G++ 4.6 gave an error but it was changed to a warning intentionally for 4.7

because many people (myself included) found that narrowing conversions where

one of the most commonly encountered problems when trying to compile large

C++03 codebases as C++11.  Previously well-formed code such as char c[] = { i,

0 }; (where i will only ever be within the range of char) caused errors and had

to be changed to char c[] = { (char)i, 0 }


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread redi at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



--- Comment #5 from Jonathan Wakely redi at gcc dot gnu.org 2012-12-22 
00:27:51 UTC ---

(In reply to comment #4)

 The standard only requires that a conforming implementation shall issue at

 least one diagnostic message



(This is from 1.4 [intro.compliance] p2)


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread david at stellarscience dot com

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783

--- Comment #6 from David Sankel david at stellarscience dot com 2012-12-22 
00:33:44 UTC ---
I suppose which gnu extensions are, by default, enabled in the -std=c++11 mode
is up for debate (one which I have no interest in). However, this program still
compiles with -pedantic.

-pedantic
   Issue all the warnings demanded by strict ISO C and ISO C++; reject all
   programs that use forbidden extensions

Allowing for these narrowing conversions would qualify as a forbidden
extension.

Regarding compliance, I think Johnathan's snippet is misleading. Here is the
relevant surrounding text:

  If a program contains a violation of any diagnosable rule or an occurrence of
a construct described in
  this Standard as “conditionally-supported” when the implementation does not
support that construct,
  a conforming implementation shall issue at least one diagnostic message.

I didn't see in the standard where it states that breaking this feature is
conditionally supported.

However, it does say:

  If a program contains a violation of a rule for which no diagnostic is
required, this International
  Standard places no requirement on implementations with respect to that
program.

Which pretty much allows gcc to do anything it wants with malformed programs.
But as stated above, -pedantic should guarentee rejection.


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread david at stellarscience dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



--- Comment #7 from David Sankel david at stellarscience dot com 2012-12-22 
00:42:35 UTC ---

I just realized my above comment doesn't make much sense regarding the

standard. Please disregard. On the other hand it seems like -pedantic should

reject this program, no?


[Bug c++/55783] Warnings instead of compiler errors for narrowing conversions within list-initializations

2012-12-21 Thread redi at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55783



Jonathan Wakely redi at gcc dot gnu.org changed:



   What|Removed |Added



   Keywords||diagnostic



--- Comment #8 from Jonathan Wakely redi at gcc dot gnu.org 2012-12-22 
00:55:31 UTC ---

Comment 6 misinterprets the standard in multiple ways :)



Narrowing conversions do require a diagnostic, but a warning *is* a diagnostic,

so G++ is compliant in this regard, this is not a GNU extension.



Whether the diagnostic should default to a warning or an error or a pedwarn

(the category of diagnostic enabled by -pedantic and made into errors by

-pedantic-errors) is debatable, but the current behaviour is the result of a

conscious decision and is not a bug (certainly not Severity=major)