Using the sample bellow, the "tcc" compiled with gcc outputs:
goto: 0x19db399 0x19db3b2 0x19db3cb
0123456789
label1
label2
label3
But the "tcc" compiled with tcc outpus:
goto: 0x7fff01952a39 0x7fff01952a52 0x7fff01952a6b
0123456789
It seems like a the addresses for the labels have different size or have
not been realocated.
-------
#include <stdio.h>
void goto_test()
{
int i;
static void *label_table[3] = { &&label1, &&label2, &&label3 };
printf("goto: %p %p %p\n", label_table[0], label_table[1],
label_table[2]);
i = 0;
/* This needs to parse as label, not as start of decl. */
typedef_and_label:
s_loop:
if (i >= 10)
goto s_end;
printf("%d", i);
i++;
goto s_loop;
s_end:
printf("\n");
/* we also test computed gotos (GCC extension) */
for(i=0;i<3;i++) {
goto *label_table[i];
label1:
printf("label1\n");
goto next;
label2:
printf("label2\n");
goto next;
label3:
printf("label3\n");
next: ;
}
}
int main() {
goto_test();
return 0;
}
On Mon, Mar 24, 2014 at 1:22 AM, Domingo Alvarez Duarte
<[email protected]>wrote:
> The tcc compiled with gcc can pass "tcctest.c" but a tcc compiled by tcc
> can't .
>
>
> On Mon, Mar 24, 2014 at 1:13 AM, Domingo Alvarez Duarte <
> [email protected]> wrote:
>
>> The problem is with jump to a computed goto:
>> void goto_test()
>> {
>> int i;
>> static void *label_table[3] = { &&label1, &&label2, &&label3 };
>> ...
>> for(i=0;i<3;i++) {
>> goto *label_table[i]; <<<<< here is the crash but on arm it works
>> fine ?????
>>
>>
>> On Mon, Mar 24, 2014 at 12:36 AM, Domingo Alvarez Duarte <
>> [email protected]> wrote:
>>
>>> I found a few more problems with my code refactoring and fixed then, now
>>> I found that the test "goto_test()" is the one that crash if I comment it
>>> all others pass.
>>>
>>> Testing on arm all tests pass including the "goto_test()", so is
>>> something with the labels calculation/generation.
>>>
>>> I'm trying to figure out what the problem is, meanwhile if someone with
>>> more knowledge on tinycc can give a help it's welcome.
>>>
>>> Thanks again for your time and attention !
>>>
>>>
>>>
>>> On Sun, Mar 23, 2014 at 12:28 AM, Domingo Alvarez Duarte <
>>> [email protected]> wrote:
>>>
>>>> Hello !
>>>>
>>>> I've been refactoring tinycc to remove global variables and work only
>>>> with TCCState after several attempts I finaly got it on a initial working
>>>> state using netbeans to do most of the refactoring work.
>>>>
>>>> Testing it on a nexus five running Ubuntu 13.10 with "make test" all
>>>> tests pass
>>>>
>>>> On Ubuntu 12.04 X86_64 the tcctest.c segfault the with "make test -i"
>>>> then others seem to passs
>>>>
>>>> I hosted on https://github.com/mingodad/tinycc it is a big patch
>>>> because it adds TCCState parameter to most of the functions.
>>>>
>>>> I hope it can be accepted to be incorparated to the main the official
>>>> repository after it stabilize, any help/sugestion are welcome.
>>>>
>>>> Thanks in advance for your time and attention !
>>>>
>>>
>>>
>>
>
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel