This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28986] Failure to diagnose overflow in constant expression
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Nov 2006 22:35:18 -0000
- Subject: [Bug c++/28986] Failure to diagnose overflow in constant expression
- References: <bug-28986-5394@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from manu at gcc dot gnu dot org 2006-11-28 22:35 -------
Roger,
The patch below fixes this bug. But it also introduces bug 19978 (multiple
warnings) in the C++ front-end. Yet, all regression testcases pass. They pass
because C++ overflow testcases are very limited and because the testsuite
cannot detect that the same warning has been emitted two times at the same
line. (Anyway to workaround the latter? How can we detect in the testcase below
that there are two "integer overflow in expression" and put a XFAIL to one of
them?)
What do you think of this?
Index: gcc/testsuite/g++.dg/conversion/nullptr1.C
===================================================================
--- gcc/testsuite/g++.dg/conversion/nullptr1.C (revision 119259)
+++ gcc/testsuite/g++.dg/conversion/nullptr1.C (working copy)
@@ -6,5 +6,5 @@
void *p = 0;
void *q = 0 * (INT_MAX + 1); // { dg-error "invalid conversion" }
+// { dg-warning "integer overflow in expression" "" { target *-*-* } 8 }
-
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c (revision 119259)
+++ gcc/cp/typeck.c (working copy)
@@ -3719,6 +3719,9 @@
result = fold_if_not_in_template (result);
if (final_type != 0)
result = cp_convert (final_type, result);
+
+ overflow_warning (result);
+
return result;
}
^L
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |roger at eyesopen dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28986