[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Bounds checking not working?
From: |
Joshua Phillips |
Subject: |
Re: [Tinycc-devel] Bounds checking not working? |
Date: |
Sat, 13 Jun 2009 17:32:34 +0000 |
User-agent: |
KMail/1.9.10 |
Hmm, interesting. Wouldn't raise(SIGSEGV) be a better action to take?
On Saturday 13 June 2009 12:20:19 grischka wrote:
> Arnold Meijster wrote:
> > 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, ...
>
> Disclaimer: TCC's bound checking is not well tested and also the
> algorithm is probably flawed in some aspects. It should work for
> simple cases though.
>
> > [...]
> > 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?
>
> Is expected. See lib/bcheck.c:
>
> /* print a bound error message */
> static void bound_error(const char *fmt, ...)
> {
> __bound_error_msg = fmt;
> *(int *)0 = 0; /* force a runtime error */
> }
>
> Basically "-b" is meant to be used with "-run" where tcc prints
> "__bound_error_msg" from its built-in exception handler:
>
> $ tcc -b -run outofbound.c
>
> You can also try the "btest" example, which runs the snippets in
> tests/boundtest.c:
>
> $ make -C tests btest
>
> --- grischka
>
>
>
>
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/tinycc-devel
signature.asc
Description: This is a digitally signed message part.