tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Re: global 64-bit variables initialization


From: Masha Rabinovich
Subject: Re: [Tinycc-devel] Re: global 64-bit variables initialization
Date: Thu, 20 Nov 2008 19:42:59 +0100

Updated test case:

int main();

int a[] = {
 2.0 ? 0 : 1,
 (_Bool)2.0,
 !2.0,
 2.0,
 (char)500,
 main ? 0 : 1, // function pointer is always true
 (int)main + (int)1e9, // be sure the result is above 1.000.000.000
 (int)main / 2, // here must be compile-time error, tcc can compile it
 sin(1) ? 0 : 1, // here must be compile-time error, tcc can compile it
};

int main()
{
  int i;
  for(i=0; i<sizeof(a)/sizeof(*a); i++) printf("%d ", a[i]);
  printf("\n");
}



On Thu, Nov 20, 2008 at 6:54 PM, Masha Rabinovich <address@hidden> wrote:

Thank you for fast response!

The test case works well now, but there is a regression:

=====

main()
{
}

void* p = main;

=====

TCC shows a compilation error.

On Thu, Nov 20, 2008 at 12:36 PM, Daniel Glöckner <address@hidden> wrote:
On Thu, Nov 20, 2008 at 08:50:22AM +0100, Masha Rabinovich wrote:
> int a = 2.0 ? 0 : 1;
> int b = (_Bool)2.0;
> int c = !2.0;
> int d = 2.0;
> int e = (char)500;
>
> int main()
> {
>   printf("%d %d %d %d %d\n", a, b, c, d, e);
> }
>
> GCC output: 0 1 0 2 -12
>
> TCC output: 1 0 1 0 500

Nice example. It triggers three bugs:
- constants are cast only inside functions
- '?' does not cast to bool
- '!' does not cast to bool

See http://repo.or.cz/w/tinycc/daniel.git

The fix for the first bug needs thorough testing before it is ready for
inclusion.

 Daniel


_______________________________________________
Tinycc-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/tinycc-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]