[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Bug in tcc
From: |
Philippe Ribet |
Subject: |
[Tinycc-devel] Bug in tcc |
Date: |
Sat, 23 Sep 2006 21:39:55 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5 |
Hello,
it tooks me 2 full days and a night to isolate this bug from huge
(generated) code.
This code works fine with gcc, whatever the optimisation level is set.
Now, I need some help to fix tcc.
Code demonstrating the bug:
#include <unistd.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct S49 T49;
typedef struct S72 T72;
typedef struct S75 T75;
typedef int*T82;
struct S49{int id;int64_t _value;};
struct S72{T82 _storage;int _capacity;int _integer_length;int
_offset;int _negative;};
struct S75{int id;int _capacity;T82 _storage;};
void* r72register1(void){
T72*C=(T72*)calloc(1, sizeof(*C));
C->_storage=(T82)(calloc(4,sizeof(int)));
C->_capacity = 4;
return (void*)C;
}
void* r72to_integer_general_number(T72* C){
T49*n=((T49*)calloc(1, sizeof(*n)));
n->id = 49;
return (void*)n;
}
void r72from_integer_64(T72* C,int64_t a1){
int _v32=0;
if(C->_capacity < 2){
C->_storage = (T82)calloc(4, sizeof(int));
C->_capacity=4;
}
if(a1 < 0) {
C->_negative = 1;
(C->_storage)[0] = (int32_t)(-(a1));
C->_offset = 0;
_v32 = (int32_t)(-(a1) >> 32);
if(_v32 == 0){
C->_integer_length = 1;
}else{
(C->_storage)[1] = _v32;
C->_integer_length = 2;
}
}
else{
C->_integer_length = 0;
C->_negative = 0;
}
}
void* r49mutable_register1(void){
T72*n = (T72*)calloc(1, sizeof(*n));
r72from_integer_64(n,INT64_C(0));
return (void*)n;
}
void* r49_ix_6443(T49* C,int64_t a1){
r72from_integer_64((T72*)(r49mutable_register1()),(C->_value));
r72from_integer_64((T72*)(r72register1()),a1);
return r72to_integer_general_number((T72*)r49mutable_register1());
}
int r75_ix_3560(T75* C, double a1){
if(a1 >= (double)INT64_MIN){
printf("here\n");
return 1;
} else{
printf("there\n");
return 0;
}
}
void* r25from_integer_64(int64_t a1){
T49*n=((T49*)calloc(1, sizeof(*n)));
n->id = 49;
n->_value = a1;
return (void*)n;
}
int main(void){
void* _n=(void*)0;
_n = r25from_integer_64(INT64_MIN);
_n = r49_ix_6443(((T49*)_n),-(INT64_C(1)));
if(r75_ix_3560((T75*)_n,(double)(INT64_MIN)) == 0){
printf("bug!\n");
} else{
printf("ok\n");
}
return 0;
}
Thanks for any help,
--
Philippe Ribet
The README file said
"Requires Windows 95, NT 4.0, or better."
So... I installed it on Linux!
- [Tinycc-devel] Bug in tcc,
Philippe Ribet <=