tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Bounds checking not working?


From: grischka
Subject: Re: [Tinycc-devel] Bounds checking not working?
Date: Sat, 13 Jun 2009 14:20:19 +0200
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)

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






reply via email to

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