[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2017-06-01 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Jonathan Wakely  changed:

   What|Removed |Added

 CC||akrzemi1 at gmail dot com

--- Comment #3 from Jonathan Wakely  ---
*** Bug 70500 has been marked as a duplicate of this bug. ***

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-06-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Jonathan Wakely  changed:

   What|Removed |Added

 CC||zhonghao at pku dot org.cn

--- Comment #4 from Jonathan Wakely  ---
*** Bug 86237 has been marked as a duplicate of this bug. ***

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-06-21 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||mpolacek at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #5 from Marek Polacek  ---
Let me try this.

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-06-25 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

--- Comment #6 from Jonathan Wakely  ---
*** Bug 86298 has been marked as a duplicate of this bug. ***

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-06-27 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Marek Polacek  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #7 from Marek Polacek  ---
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01691.html

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-07-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

--- Comment #8 from Jonathan Wakely  ---
*** Bug 86596 has been marked as a duplicate of this bug. ***

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-08-06 Thread tadeus.prastowo at unitn dot it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

--- Comment #9 from Tadeus Prastowo  ---
This problem still exists in the trunk (cf. https://godbolt.org/g/bRf18i). 
Clang correctly keeps rejecting it (cf. https://godbolt.org/g/egcNtV).  Both
use the following MWE:

template
struct X {
  static constexpr unsigned data {a};
};

int main() {
  return X<-1>::data;
}

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-08-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

--- Comment #10 from Marek Polacek  ---
Right, we're still hashing this out on the mailing list.  But I expect it to be
fixed soon.

There are similar cases not handled by my current patch, but I'll work on those
next.

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-08-13 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

--- Comment #11 from Marek Polacek  ---
Author: mpolacek
Date: Mon Aug 13 23:12:11 2018
New Revision: 263523

URL: https://gcc.gnu.org/viewcvs?rev=263523&root=gcc&view=rev
Log:
PR c++/57891
* call.c (struct conversion): Add check_narrowing_const_only.
(build_converted_constant_expr): Set check_narrowing and
check_narrowing_const_only.  Give error if expr is error node.
(convert_like_real): Pass it to check_narrowing.
* cp-tree.h (check_narrowing): Add a default parameter.
* decl.c (compute_array_index_type): Use input_location instead of
location_of.
* pt.c (convert_nontype_argument): Return NULL_TREE if tf_error.
* typeck2.c (check_narrowing): Don't warn for instantiation-dependent
expressions.  Call maybe_constant_value instead of
fold_non_dependent_expr.  Don't mention { } in diagnostic.  Only check
narrowing for constants if CONST_ONLY.

* g++.dg/cpp0x/Wnarrowing6.C: New test.
* g++.dg/cpp0x/Wnarrowing7.C: New test.
* g++.dg/cpp0x/Wnarrowing8.C: New test.
* g++.dg/cpp0x/Wnarrowing9.C: New test.
* g++.dg/cpp0x/Wnarrowing10.C: New test.
* g++.dg/cpp0x/constexpr-47969.C: Adjust dg-error.
* g++.dg/cpp0x/constexpr-ex2.C: Likewise.
* g++.dg/cpp0x/constexpr-targ.C: Likewise.
* g++.dg/cpp0x/scoped_enum2.C: Likewise.
* g++.dg/ext/stmtexpr15.C: Likewise.
* g++.dg/gomp/pr47963.C: Likewise.
* g++.dg/init/new37.C: Likewise.
* g++.dg/init/new43.C: Likewise.
* g++.dg/other/fold1.C: Likewise.
* g++.dg/parse/array-size2.C: Likewise.
* g++.dg/template/dependent-name3.C: Likewise.
* g++.dg/cpp0x/constexpr-data2.C: Add dg-error.
* g++.dg/other/vrp1.C: Likewise.
* g++.dg/template/char1.C: Likewise.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/Wnarrowing10.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wnarrowing6.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wnarrowing7.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wnarrowing8.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wnarrowing9.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/decl.c
trunk/gcc/cp/pt.c
trunk/gcc/cp/typeck2.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C
trunk/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C
trunk/gcc/testsuite/g++.dg/ext/stmtexpr15.C
trunk/gcc/testsuite/g++.dg/gomp/pr47963.C
trunk/gcc/testsuite/g++.dg/init/new37.C
trunk/gcc/testsuite/g++.dg/init/new43.C
trunk/gcc/testsuite/g++.dg/other/fold1.C
trunk/gcc/testsuite/g++.dg/other/vrp1.C
trunk/gcc/testsuite/g++.dg/parse/array-size2.C
trunk/gcc/testsuite/g++.dg/template/char1.C
trunk/gcc/testsuite/g++.dg/template/dependent-name3.C

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2018-08-13 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Marek Polacek  changed:

   What|Removed |Added

   Keywords||accepts-invalid
 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from Marek Polacek  ---
Fixed for GCC 9.

[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2013-07-13 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2013-07-13
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
I thought we already had a bug report about this, because we fixed some cases
in libstdc++ that G++ accepted but clang rejected, but I can't find it now.


[Bug c++/57891] No diagnostic of narrowing conversion in non-type template argument

2014-03-31 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57891

Jonathan Wakely  changed:

   What|Removed |Added

 CC||filip.roseen at gmail dot com

--- Comment #2 from Jonathan Wakely  ---
*** Bug 60715 has been marked as a duplicate of this bug. ***