Skip to content

Commit 7ea4cfc

Browse files
committedApr 22, 2015
[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 llvm-svn: 235518
1 parent cab5678 commit 7ea4cfc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ int main(int argc, char **argv) {
8787
static int test_int = MaxFloatRepresentableAsInt + 0x80;
8888
return 0;
8989
}
90-
case '1':
90+
case '1': {
9191
// CHECK-1: runtime error: value -2.14748{{.*}} is outside the range of representable values of type 'int'
92-
return MinFloatRepresentableAsInt - 0x100;
92+
static int test_int = MinFloatRepresentableAsInt - 0x100;
93+
return 0;
94+
}
9395
case '2': {
9496
// CHECK-2: runtime error: value -1 is outside the range of representable values of type 'unsigned int'
9597
volatile float f = -1.0;
@@ -107,9 +109,11 @@ int main(int argc, char **argv) {
107109
static int test_int = Inf;
108110
return 0;
109111
}
110-
case '5':
112+
case '5': {
111113
// CHECK-5: runtime error: value {{.*}} is outside the range of representable values of type 'int'
112-
return NaN;
114+
static int test_int = NaN;
115+
return 0;
116+
}
113117

114118
// Integer -> floating point overflow.
115119
case '6': {

0 commit comments

Comments
 (0)
Please sign in to comment.