tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Bug: array references with long long ints on i386


From: ghe
Subject: [Tinycc-devel] Bug: array references with long long ints on i386
Date: Sat, 9 Jun 2012 15:57:03 +0200 (CEST)
User-agent: Alpine 2.00 (NEB 1167 2008-08-23)


Hi list,

Here is a simple C program that does not compile and execute correclty with TCC (on i386, both with TCC 0.9.25 and with the latest sources; it works on AMD64):

#include <stdio.h>

long long int ll[] = { 1LL, 2LL };
unsigned long long int ull[] = { 1ULL, 2ULL };

int main ()
{
  long long int lli;
  unsigned long long int ulli;
  lli = 1LL;
  printf ("%lld ", ll[lli]); printf ("%lld ", ll[1LL]); printf ("%lld\n", 
ll[1]);
  printf ("%lld %lld %lld\n", ll[lli], ll[1LL], ll[1]);
  if (ll[lli] == 2LL) printf ("OK "); else printf ("KO ");
  if (ll[1LL] == 2LL) printf ("OK "); else printf ("KO ");
  if (ll[1] == 2LL) printf ("OK\n"); else printf ("KO\n");
  ulli = 1ULL;
  printf ("%llu ", ull[ulli]); printf ("%llu ", ull[1ULL]); printf ("%llu\n", 
ull[1]);
  printf ("%llu %llu %llu\n", ull[ulli], ull[1ULL], ull[1]);
  if (ull[ulli] == 2ULL) printf ("OK "); else printf ("KO ");
  if (ull[1ULL] == 2ULL) printf ("OK "); else printf ("KO ");
  if (ull[1] == 2ULL) printf ("OK\n"); else printf ("KO\n");
  return 0;
}

It should obviously print:

2 2 2
2 2 2
OK OK OK
2 2 2
2 2 2
OK OK OK

but it prints:

0 2 2
2 2 2
KO OK OK
0 2 2
2 2 2
KO OK OK

--ghe



reply via email to

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