mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
52 lines
847 B
C
52 lines
847 B
C
|
/* bug #1265 - misadjusted stack from unprototyped function call */
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
int failures = 0;
|
||
|
|
||
|
char str1[10];
|
||
|
char str2[10];
|
||
|
|
||
|
int f2 (int x) { return x == 2345 ? 23 : -1; }
|
||
|
|
||
|
int main (void) {
|
||
|
int x, n;
|
||
|
|
||
|
sprintf (str1, "%p\n", &x);
|
||
|
puts(str1);
|
||
|
x = 1234;
|
||
|
n = f1 (x);
|
||
|
sprintf (str2, "%p\n", &x);
|
||
|
puts(str2);
|
||
|
|
||
|
if (strcmp(str1, str2)) {
|
||
|
puts("not equal");
|
||
|
failures++;
|
||
|
}
|
||
|
if (n != 42) {
|
||
|
puts("f1 returns wrong value");
|
||
|
failures++;
|
||
|
}
|
||
|
|
||
|
sprintf (str1, "%p\n", &x);
|
||
|
puts(str1);
|
||
|
x = 2345;
|
||
|
n = f2 (x);
|
||
|
sprintf (str2, "%p\n", &x);
|
||
|
puts(str2);
|
||
|
|
||
|
if (strcmp(str1, str2)) {
|
||
|
puts("not equal");
|
||
|
failures++;
|
||
|
}
|
||
|
if (n != 23) {
|
||
|
puts("f2 returns wrong value");
|
||
|
failures++;
|
||
|
}
|
||
|
|
||
|
return failures;
|
||
|
}
|
||
|
|
||
|
int f1 (int x) { return x == 1234 ? 42 : -1; }
|