mirror of
https://github.com/TinyCC/tinycc.git
synced 2025-11-16 12:34:45 +00:00
fix UB in constant folding of double -> signed integer conversion
This commit is contained in:
10
tests/tests2/134_double_to_signed.c
Normal file
10
tests/tests2/134_double_to_signed.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("%d\n", (int)-1.0);
|
||||
double d = -1.0;
|
||||
printf("%d\n", (int)d);
|
||||
|
||||
printf("%d\n", (int)-2147483648.0);
|
||||
d = -2147483648.0;
|
||||
printf("%d\n", (int)d);
|
||||
}
|
||||
4
tests/tests2/134_double_to_signed.expect
Normal file
4
tests/tests2/134_double_to_signed.expect
Normal file
@@ -0,0 +1,4 @@
|
||||
-1
|
||||
-1
|
||||
-2147483648
|
||||
-2147483648
|
||||
Reference in New Issue
Block a user