This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR c++/28986 failure to diagnose overflow for binary operators


:ADDPATCH c++:

Somehow the C++ front-end is not able to diagnose overflow for the
result of binary operators. The fix is trivial (I can hardly believe
that this is not a regression). In addition, I have adapted the
overflow testcases from the C front-end to the C++ testsuite with some
minor modifications. For reference, I also provide a diff showing
those modifications.

One particular issue that I am not sure about is whether initialisers
for static variables need to be constant in C++ as they do in C. The
relevant hunk in the diff between C and C++ testcases is:

-/* But this expression does need to be constant.  */
+/* But this expression does need to be constant (in C++ ???).  */
static int sc = INT_MAX + 1; /* { dg-warning "warning: integer
overflow in expression" } */
-/* { dg-warning "warning: overflow in constant expression" "constant"
{ target *-*-* } 47 } */
+/* { dg-warning "warning: overflow in constant expression" "constant"
{ xfail *-*-* } 47 } */


Bootstrapped and tested with --enable-languages=all on i686-pc-linux-gnu for revision 120511.

cp/
2007-01-06  Manuel Lopez-Ibanez <manu@gcc.gnu.org>

   PR c++/28986
   * typeck.c (build_binary_op): Call overflow_warning if
TREE_OVERFLOW_P is true for the result and not for any of the
operands.

testsuite/
2007-01-06  Manuel Lopez-Ibanez <manu@gcc.gnu.org>

   PR c++/28986
   * g++.dg/conversion/nullptr1.C: Added overflow warning.
   * g++.dg/warn/multiple-overflow-warn-2.C: New.
   * g++.dg/warn/overflow-warn-1.C: New.
   * g++.dg/warn/overflow-warn-2.C: New.
   * g++.dg/warn/overflow-warn-3.C: New.
   * g++.dg/warn/overflow-warn-4.C: New.
   * g++.dg/warn/overflow-warn-5.C: New.
   * g++.dg/warn/overflow-warn-6.C: New.
   * g++.dg/warn/Woverflow-1.C: New.
   * g++.dg/warn/Woverflow-2.C: New.
   * g++.dg/warn/Woverflow-3.C: New.

Attachment: c-c++-overflow-testsuite.diff
Description: Text document

Attachment: c++-overflow-warning.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]