tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Predefined macro identifying TinyC?


From: Ben Bacarisse
Subject: Re: [Tinycc-devel] Predefined macro identifying TinyC?
Date: Mon, 16 Mar 2015 14:07:17 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Martin Guy <address@hidden> writes:
<snip>
> The reason is to work round what looks like a bug in the 64-bit
> pointer handling, which is
> fairly easy to workaround:
>
> /* Tickle a bug in TinyC on 64-bit systems:
>  * the LSB of the top word or ARGP gets set
>  * for no obvious reason.
>  *
>  * Source: a legacy language interpreter which
>  * has a little stack / stack pointer for arguments.
>  *
>  * Output is: 0x8049620 0x10804961c
>  * Should be: 0x8049620 0x804961c
>  */
>
> #define NARGS 20000
> int ARG[NARGS];
> int *ARGSPACE = ARG;
> int *ARGP = ARG - 1;

As it happens, this is undefined behaviour by the C language standard --
you can't even construct (let alone use) a pointer that points "before"
the start of an array.  I don't know whether TinyC is using the
permission this gives the implementation, but it is technically free to
do whatever it likes in this situation.

<snip>
-- 
Ben.



reply via email to

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