diff options
author | Michael Forney <mforney@mforney.org> | 2021-10-25 15:59:54 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-10-25 17:01:43 -0700 |
commit | e79005956c888e7bafb602df1137f881b34775ec (patch) | |
tree | 2267161bfb9b9cc5e065691cb75ef9679ca4b5ad /test | |
parent | 9540626e5793583b6feb36d025dc640c7cb97cc8 (diff) |
eval: Fix int-to-float conversions
Also, add bounds checks for float-to-int conversions. If the integer
part can't be represented in the result type, C behavior is undefined.
Although this means the result is arbitrary, we need to avoid
undefined behavior in cproc itself when given such a program as
input.
Diffstat (limited to 'test')
-rw-r--r-- | test/initializer-cast-float-int.c | 1 | ||||
-rw-r--r-- | test/initializer-cast-float-int.qbe | 1 | ||||
-rw-r--r-- | test/initializer-cast-int-float.c | 1 | ||||
-rw-r--r-- | test/initializer-cast-int-float.qbe | 1 |
4 files changed, 4 insertions, 0 deletions
diff --git a/test/initializer-cast-float-int.c b/test/initializer-cast-float-int.c new file mode 100644 index 0000000..42296e9 --- /dev/null +++ b/test/initializer-cast-float-int.c @@ -0,0 +1 @@ +int x = -1.0; diff --git a/test/initializer-cast-float-int.qbe b/test/initializer-cast-float-int.qbe new file mode 100644 index 0000000..675fc96 --- /dev/null +++ b/test/initializer-cast-float-int.qbe @@ -0,0 +1 @@ +export data $x = align 4 { w 18446744073709551615, } diff --git a/test/initializer-cast-int-float.c b/test/initializer-cast-int-float.c new file mode 100644 index 0000000..e041d90 --- /dev/null +++ b/test/initializer-cast-int-float.c @@ -0,0 +1 @@ +double x = -1; diff --git a/test/initializer-cast-int-float.qbe b/test/initializer-cast-int-float.qbe new file mode 100644 index 0000000..80b905e --- /dev/null +++ b/test/initializer-cast-int-float.qbe @@ -0,0 +1 @@ +export data $x = align 8 { d d_-1, } |