mirror of
https://github.com/cc65/cc65.git
synced 2025-03-03 09:32:33 +00:00
test for issue #327
This commit is contained in:
parent
ff18218b0a
commit
2428285694
34
test/todo/bug327.c
Normal file
34
test/todo/bug327.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* bug #327 - Promoting u8 to s16 gives wrong result */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint8_t arr[2] = {
|
||||
0,
|
||||
255
|
||||
};
|
||||
|
||||
static int16_t get16() {
|
||||
return -arr[1];
|
||||
}
|
||||
|
||||
static int16_t get16_2() {
|
||||
return -(int16_t) arr[1];
|
||||
}
|
||||
|
||||
char res = 0;
|
||||
|
||||
int main() {
|
||||
|
||||
printf("Value %d, should be -255\n", get16());
|
||||
printf("Value %d, should be -255\n", get16_2());
|
||||
|
||||
if (get16() != -255) {
|
||||
res++;
|
||||
}
|
||||
if (get16_2() != -255) {
|
||||
res++;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user