diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-23 15:43:01 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-23 15:43:01 -0800 |
commit | b86abc2ecfea9ccbb93cad2fe4e9f8574beb7ed8 (patch) | |
tree | e966f2fd2bc38d15c18fa880098ba5c8b91f07eb /tests | |
parent | 9b3e1b8d8e948709a9df1a23ea8790c93eb5b82e (diff) |
fix bug where close-together tempDoublePtr operations could cross each other
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/closebitcasts.c | 32 | ||||
-rw-r--r-- | tests/core/closebitcasts.txt | 2 | ||||
-rw-r--r-- | tests/test_core.py | 6 |
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/core/closebitcasts.c b/tests/core/closebitcasts.c new file mode 100644 index 00000000..2c9d5ab5 --- /dev/null +++ b/tests/core/closebitcasts.c @@ -0,0 +1,32 @@ +#include <stdio.h> + +int main(int argc, char **argv) { + float x = argc%17, y = (argc+1)*(argc+2)*(argc+3)*(argc+4)*(argc*5); + y *= 1<<30; + y *= -13; + if (argc == 17) { x++; y--; } + int *xi = (int*)&x; + int *yi = (int*)&y; + int z = *xi - *yi; + while (z % 15) { + z++; + } + printf("!%d\n", z); + + double xd = x, yd = y; + yd = yd*yd; + yd = yd*yd; + int *xl = (int*)&xd; + int *xh = &((int*)&xd)[1]; + int *yl = (int*)&yd; + int *yh = &((int*)&yd)[1]; + int l = *xl - *yl; + int h = *xh - *yh; + while (l % 15) { + l++; + h += 3; + } + printf("%d,%d!\n", l, h); + return 0; +} + diff --git a/tests/core/closebitcasts.txt b/tests/core/closebitcasts.txt new file mode 100644 index 00000000..f97366cd --- /dev/null +++ b/tests/core/closebitcasts.txt @@ -0,0 +1,2 @@ +!1787576325 +589815810,-179981561! diff --git a/tests/test_core.py b/tests/test_core.py index 2430aa1c..5a19ef0c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -771,6 +771,12 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output) + def test_closebitcasts(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2') + test_path = path_from_root('tests', 'core', 'closebitcasts') + src, output = (test_path + s for s in ('.c', '.txt')) + self.do_run_from_file(src, output) + def test_fast_math(self): if self.emcc_args is None: return self.skip('requires emcc') Building.COMPILER_TEST_OPTS += ['-ffast-math'] |