[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Bounds checking not working?
From: |
Arnold Meijster |
Subject: |
[Tinycc-devel] Bounds checking not working? |
Date: |
Fri, 12 Jun 2009 17:06:26 +0200 |
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:
address@hidden:~$ 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;
}
address@hidden:~$ uname -a
Linux wingtip82 2.6.26 #1 SMP Sun Mar 29 12:17:22 CEST 2009 i686
GNU/Linux
address@hidden:~$ tcc outofbound.c
address@hidden:~$ ./a.out
Before
After
address@hidden:~$ tcc -b -g outofbound.c
address@hidden:~$ ./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] Bounds checking not working?,
Arnold Meijster <=