[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] segfault with static array initialized by a macro
From: |
Didier Barvaux |
Subject: |
[Tinycc-devel] segfault with static array initialized by a macro |
Date: |
Sat, 20 Oct 2012 19:03:19 +0200 |
Hello all,
In encountered what seems to be a bug in TCC (git revision
ad5f3758c38f2364f03205dcb9fd48142d2d4499). I narrowed it down to the
following test case.
$ cat segfault_with_static_array.c
#include <stdio.h>
#define LENGTH1 10
#define LENGTH2 20
#define max(a, b) (((a) > (b)) ? (a) : (b))
int main(int argc, char *argv[])
{
static unsigned char data[max(LENGTH1, LENGTH2)];
printf("max(%d, %d) = %d\n", LENGTH1, LENGTH2, max(LENGTH1,
LENGTH2)); printf("data = %p\n", data);
data[0] = 0x42;
return 0;
}
$ tcc -o segfault_with_static_array -Wall -Werror \
segfault_with_static_array.c
$ ./segfault_with_static_array
max(10, 20) = 20
data = (nil)
Erreur de segmentation
$ echo $?
139
The program above works with GCC 4.5, GCC 4.6, GCC 4.7 and Clang 3.1.
It does not fail with TCC if I do not use the max() macro or remove the
'static' keyword for the 'data' array.
Regards,
Didier
signature.asc
Description: PGP signature
- [Tinycc-devel] segfault with static array initialized by a macro,
Didier Barvaux <=