fix UB in constant folding of double -> signed integer conversion

This commit is contained in:
Guest0x0
2024-09-14 06:09:26 +00:00
parent 12acbf3e92
commit b8b6a5fd7b
3 changed files with 18 additions and 1 deletions

View 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);
}

View File

@@ -0,0 +1,4 @@
-1
-1
-2147483648
-2147483648