From 5925a7f8eec335b5c566c93c345ab044e1fc8b23 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 9 Jul 2020 16:16:46 +0200 Subject: [PATCH] test for issue #1077 --- test/todo/bug1077.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/todo/bug1077.c diff --git a/test/todo/bug1077.c b/test/todo/bug1077.c new file mode 100644 index 000000000..2fb3ef168 --- /dev/null +++ b/test/todo/bug1077.c @@ -0,0 +1,31 @@ +/* bug #1077 - Wrong code: a non-array constant address with a non-constant subscript */ + +#include +#include + +int test1(void) +{ + int a = 0; + (&a)[a] = 42; + return a; +} +int test2(void) +{ + int a = 0; + int b = 0; + (&a)[b] = 42; + return a; +} + +int main(void) +{ + int res, ret = EXIT_SUCCESS; + res = test1(); + printf("%d\n", res); + if (res != 42) ret = EXIT_FAILURE; + res = test2(); + printf("%d\n", res); + if (res != 42) ret = EXIT_FAILURE; + + return ret; +}