Hi,

I just subscribed to the devel-list so don't flame me if 
I write this to the wrong list, please.

I will be teaching a course in C programming at the university
and was looking for a C compiler/interpreter that does 
bound checking (for first year's students that seems to be a good idea).
After some googling, I found tcc. It seems to be perfect for what I 
want, however after compiling it, I tried the following:

arn...@wingtip82:~$ cat outofbound.c
#include <stdio.h>

int main(int argc, char **argv) {
  int i, sum, tab[10];
  
  printf ("Before\n");
  sum = 0;
  for(i=0;i<11;i++) {
    sum += tab[i];
  }
  printf ("After\n");
  return 0;
}
arn...@wingtip82:~$ uname -a
Linux wingtip82 2.6.26 #1 SMP Sun Mar 29 12:17:22 CEST 2009 i686
GNU/Linux
arn...@wingtip82:~$ tcc outofbound.c
arn...@wingtip82:~$ ./a.out
Before
After
arn...@wingtip82:~$ tcc -b -g outofbound.c
arn...@wingtip82:~$ ./a.out
Before
Segmentation fault


As you can see, the boundschecking version is somewhat different; it
crashes instead of running on without any error (as without checking).
However, I don't think this is the behaviour to be expected, or is it?

Regards,

  Arnold Meijster




_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to