[compiler-rt] r235518 - [ubsan] Stop cast-overflow.cpp test leaking undefined behaviour into the exit code.

Daniel Sanders daniel.sanders at imgtec.com
Wed Apr 22 09:14:02 PDT 2015


Author: dsanders
Date: Wed Apr 22 11:14:01 2015
New Revision: 235518

URL: http://llvm.org/viewvc/llvm-project?rev=235518&view=rev
Log:
[ubsan] Stop cast-overflow.cpp test leaking undefined behaviour into the exit code.

Summary:
ubsan was correctly catching the undefined behaviour but lit's shell was
failing the test anyway because the exit code was non-zero as a result of the
undefined behaviour.

This fixes the test on a mips-linux-gnu target.

Reviewers: samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits, rsmith, sagar

Differential Revision: http://reviews.llvm.org/D9155

Modified:
    compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp

Modified: compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp?rev=235518&r1=235517&r2=235518&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp Wed Apr 22 11:14:01 2015
@@ -87,9 +87,11 @@ int main(int argc, char **argv) {
     static int test_int = MaxFloatRepresentableAsInt + 0x80;
     return 0;
     }
-  case '1':
+  case '1': {
     // CHECK-1: runtime error: value -2.14748{{.*}} is outside the range of representable values of type 'int'
-    return MinFloatRepresentableAsInt - 0x100;
+    static int test_int = MinFloatRepresentableAsInt - 0x100;
+    return 0;
+  }
   case '2': {
     // CHECK-2: runtime error: value -1 is outside the range of representable values of type 'unsigned int'
     volatile float f = -1.0;
@@ -107,9 +109,11 @@ int main(int argc, char **argv) {
     static int test_int = Inf;
     return 0;
   }
-  case '5':
+  case '5': {
     // CHECK-5: runtime error: value {{.*}} is outside the range of representable values of type 'int'
-    return NaN;
+    static int test_int = NaN;
+    return 0;
+  }
 
     // Integer -> floating point overflow.
   case '6': {





More information about the llvm-commits mailing list