[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-05-04 Thread evangelos at foutrelis dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Evangelos Foutras evangelos at foutrelis dot com changed:

   What|Removed |Added

 CC||evangelos at foutrelis dot com

--- Comment #23 from Evangelos Foutras evangelos at foutrelis dot com ---
Please note that narrowing conversions don't seem to work the same way they did
in GCC 4.9; I've filed PR c++/66007 for this change in behavior.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-30 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |5.2

--- Comment #22 from Paolo Carlini paolo.carlini at oracle dot com ---
Fixed for 5.2 too.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-30 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #21 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org ---
Author: paolo
Date: Thu Apr 30 16:31:36 2015
New Revision: 222636

URL: https://gcc.gnu.org/viewcvs?rev=222636root=gccview=rev
Log:
/cp
2015-04-30  Paolo Carlini  paolo.carl...@oracle.com

PR c++/65801
* typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing
suppresses the diagnostic.

2015-04-30  Paolo Carlini  paolo.carl...@oracle.com

PR c++/65801
* doc/invoke.texi ([-Wnarrowing]): Update.

/testsuite
2015-04-30  Paolo Carlini  paolo.carl...@oracle.com

PR c++/65801
* g++.dg/cpp0x/Wnarrowing2.C: New.

Added:
branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/Wnarrowing2.C
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/cp/ChangeLog
branches/gcc-5-branch/gcc/cp/typeck2.c
branches/gcc-5-branch/gcc/doc/invoke.texi
branches/gcc-5-branch/gcc/testsuite/ChangeLog


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-21 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #16 from Manuel López-Ibáñez manu at gcc dot gnu.org ---

What is printed with -Wno-error=narrowing ?

[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-21 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #18 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #16)
 What is printed with -Wno-error=narrowing ?

I'm also a bit afraid of how setting pedantic-errors in this way interacts with
the #pragma GCC diagnostics. Wouldn't it be better to reclassify -Wnarrowing as
an error (see diagnostic_classify_diagnostic) then simulate a #pragma GCC
diagnostics pop to restore the previous state? The problem is the order in
which the re-classification happens, which should appear as if it happened in
the command-line and not at the point of warning, but
diagnostic_classify_diagnostic assumes #pragmas are handled in the order given
in the source code.

Another alternative, perhaps simpler, would be to have a different option
-Wnarrowing-strict, which by default is -Werror=narrowing-strict (see
Werror-implicit-function-declaration) and it is enabled by -Wnarrowing. This
way, everything should work as expected (unless latent bugs in the options
handling machinery for not passing the error/warning state correctly when
enabling dependant options).

An even simpler options is to put this under -fpermissive so people realize
that what they are doing is very wrong according to the standard (if it is not
very wrong, then why error and not just pedwarn?).

[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-21 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #17 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #16)
 What is printed with -Wno-error=narrowing ?

Try it yourself?
Just a warning.

[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-21 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #19 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Markus Trippelsdorf from comment #17)
 (In reply to Manuel López-Ibáñez from comment #16)
  What is printed with -Wno-error=narrowing ?
 
 Try it yourself?
 Just a warning.

Thanks, well at least that works. I guess if someone notices a problem with the
#pragmas, a better solution can be found later.

[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #20 from Jonathan Wakely redi at gcc dot gnu.org ---
The problem with -fpermissive is that it doesn't just allow things like
narrowing that are valid in C++03 but also allows all kind of ancient
constructs that no sane person wants.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #15 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org ---
Author: paolo
Date: Mon Apr 20 21:46:59 2015
New Revision: 49

URL: https://gcc.gnu.org/viewcvs?rev=49root=gccview=rev
Log:
/cp
2015-04-20  Paolo Carlini  paolo.carl...@oracle.com

PR c++/65801
* typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing
suppresses the diagnostic.

2015-04-20  Paolo Carlini  paolo.carl...@oracle.com

PR c++/65801
* doc/invoke.texi ([-Wnarrowing]): Update.

/testsuite
2015-04-20  Paolo Carlini  paolo.carl...@oracle.com

PR c++/65801
* g++.dg/cpp0x/Wnarrowing2.C: New.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/Wnarrowing2.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck2.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #14 from Jakub Jelinek jakub at gcc dot gnu.org ---
(In reply to Paolo Carlini from comment #13)
 Ok, I'll commit it in an hour or so to trunk. Is it too late for 5.1?

It is IMHO too late for that, but not too late for 5.2.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #13 from Paolo Carlini paolo.carlini at oracle dot com ---
Ok, I'll commit it in an hour or so to trunk. Is it too late for 5.1?


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #12 from Jason Merrill jason at gcc dot gnu.org ---
(In reply to Paolo Carlini from comment #11)
 Draft patch 2

I think let's go with this.  It's odd, but not complex and does what we want.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek mpolacek at gcc dot gnu.org ---
Couldn't you simply turn the error_at into pedwarn?


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #3 from Paolo Carlini paolo.carlini at oracle dot com ---
Ok, thus what shall we do? Shall we go back to my minimal patch which only
touched enums? https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00880.html


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #5 from Paolo Carlini paolo.carlini at oracle dot com ---
Well, at the time I think we agreed that we wanted to be strict at least about
enums... Otherwise, yes, we can do that plus setting ok = true in that case
too, thus collapsing the last two ifs (+ reverting the docs change and
adjusting the testsuite).


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #7 from Paolo Carlini paolo.carlini at oracle dot com ---
Yes, I was thinking that in such cases clang does something we don't normally
do (ie, an hard error by default suppressible with a -Wno-*). Let me see if we
can achieve that as you suggested.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #6 from Jason Merrill jason at gcc dot gnu.org ---
(In reply to Paolo Carlini from comment #5)
 Well, at the time I think we agreed that we wanted to be strict at least
 about enums... Otherwise, yes, we can do that plus setting ok = true in that
 case too, thus collapsing the last two ifs (+ reverting the docs change and
 adjusting the testsuite).

I think that for constants, we want it to be an error without -Wno-narrowing. 
I wonder if the best way to get that is to set pedantic_errors around the
pedwarn call?


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #9 from Paolo Carlini paolo.carlini at oracle dot com ---
Created attachment 35367
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=35367action=edit
Draft patch


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #8 from Paolo Carlini paolo.carlini at oracle dot com ---
Jason, as far as I can see *nowhere* else in the compiler we fiddle with
flag_pedantic_errors, all the tweaks I tried look super hackish to me :( If we
are Ok with just going back to pedwarns the attached passes testing...


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #11 from Paolo Carlini paolo.carlini at oracle dot com ---
Created attachment 35370
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=35370action=edit
Draft patch 2


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-20 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

--- Comment #10 from Paolo Carlini paolo.carlini at oracle dot com ---
I'm also attaching what I have for the forced pedantic-errors idea.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-19 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Jason Merrill jason at gcc dot gnu.org changed:

   What|Removed |Added

 CC||paolo.carlini at oracle dot com

--- Comment #2 from Jason Merrill jason at gcc dot gnu.org ---
This changed with Paolo's r213776.  These examples suggest that the change to
constant handling WRT -Wnarrowing was a mistake.


[Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules

2015-04-18 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801

Markus Trippelsdorf trippels at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-04-18
 CC||trippels at gcc dot gnu.org
Summary|Allow -Wno-narrowing to |[5/6 Regression] Allow
   |silence stricter C++11  |-Wno-narrowing to silence
   |narrowing rules |stricter C++11 narrowing
   ||rules
 Ever confirmed|0   |1

--- Comment #1 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
Yes. This also breaks building Chromium.

markus@x4 ~ % echo int main () {int i = { 0x };} | g++ -std=c++11
-Wno-narrowing -x c++ -
stdin: In function ‘int main()’:
stdin:1:35: error: narrowing conversion of ‘4294967295u’ from ‘unsigned int’
to ‘int’ inside { }

While the standard is clear that this is an error,
accepting -Wno-narrowing as in 4.8, 4.9 and clang looks acceptable to me.