1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-17 09:07:32 +00:00
cc65/test/val/bug1077.c

32 lines
516 B
C
Raw Normal View History

2020-07-09 14:16:46 +00:00
/* bug #1077 - Wrong code: a non-array constant address with a non-constant subscript */
#include <stdlib.h>
#include <stdio.h>
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;
}