From d712dfff74f1b6f1f38c92c44b6fb8fdf716b49a Mon Sep 17 00:00:00 2001 From: pfg Date: Fri, 15 Nov 2013 03:05:33 +0000 Subject: gcc: warn about integer overflow in constant expressions in the C++ frontend. This fixes GCC 28986: http://gcc.gnu.org/ml/gcc-patches/2007-01/msg00473.html Obtained from: gcc 4.3 (rev. 120558; GPLv2) MFC after: 3 weeks --- contrib/gcc/cp/typeck.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'contrib/gcc') diff --git a/contrib/gcc/cp/typeck.c b/contrib/gcc/cp/typeck.c index 6b28f49..dd92b22 100644 --- a/contrib/gcc/cp/typeck.c +++ b/contrib/gcc/cp/typeck.c @@ -3773,6 +3773,12 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, result = fold_if_not_in_template (result); if (final_type != 0) result = cp_convert (final_type, result); + + if (TREE_OVERFLOW_P (result) + && !TREE_OVERFLOW_P (op0) + && !TREE_OVERFLOW_P (op1)) + overflow_warning (result); + return result; } -- cgit v1.1