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]

Re: [PATCH] Add signed integer overflow checking to ubsan


On Fri, Nov 22, 2013 at 02:55:52PM +0100, Jakub Jelinek wrote:
> On Fri, Nov 22, 2013 at 10:54:16AM +0100, Marek Polacek wrote:
> > 1) currently, we seem to miscompile some code with -Os.  That's why
> >    I skipped -Os in some of the test.
> 
> The following (untested) incremental fix should hopefully fix it.
> 
> Perhaps the calls before expand_normal aren't needed, dunno if we can end up
> with any pending stack adjustments in between gimple stmts.
> But the ones after expand_normal (fn); certainly are needed, if we the
> calls change sp, we need to return back to the previous state of sp
> before the CODE_LABEL that can be jumped to to bypass the call.

...and the following makes the tests run with -Os again.

2013-11-22  Marek Polacek  <polacek@redhat.com>

testsuite/
	* c-c++-common/ubsan/overflow-sub-1.c: Run the test even with -Os.
	* c-c++-common/ubsan/overflow-mul-1.c: Likewise.
	* c-c++-common/ubsan/overflow-add-1.c: Likewise.

--- gcc/testsuite/c-c++-common/ubsan/overflow-sub-1.c.mp2	2013-11-22 15:14:23.350971273 +0100
+++ gcc/testsuite/c-c++-common/ubsan/overflow-sub-1.c	2013-11-22 15:15:43.490276963 +0100
@@ -1,9 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
 /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
-/* { dg-skip-if "" { *-*-* }  { "-Os" } { "" } } */
-
-// TODO: This is miscompiled with -Os!
 
 #define SCHAR_MAX __SCHAR_MAX__
 #define SCHAR_MIN (-__SCHAR_MAX__ - 1)
--- gcc/testsuite/c-c++-common/ubsan/overflow-mul-1.c.mp2	2013-11-22 15:14:05.007904024 +0100
+++ gcc/testsuite/c-c++-common/ubsan/overflow-mul-1.c	2013-11-22 15:15:22.932196728 +0100
@@ -1,9 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
 /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
-/* { dg-skip-if "" { *-*-* }  { "-Os" } { "" } } */
-
-// TODO: This is miscompiled with -Os!
 
 #define SCHAR_MAX __SCHAR_MAX__
 #define SHRT_MAX __SHRT_MAX__
--- gcc/testsuite/c-c++-common/ubsan/overflow-add-1.c.mp2	2013-11-22 15:13:50.506851027 +0100
+++ gcc/testsuite/c-c++-common/ubsan/overflow-add-1.c	2013-11-22 15:14:53.409081665 +0100
@@ -1,9 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
 /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
-/* { dg-skip-if "" { *-*-* }  { "-Os" } { "" } } */
-
-// TODO: This is miscompiled with -Os!
 
 #define SCHAR_MAX __SCHAR_MAX__
 #define SHRT_MAX __SHRT_MAX__

	Marek


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