[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.
- [Tinycc-devel] Predefined macro identifying TinyC?, Martin Guy, 2015/03/16
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Edmund Grimley Evans, 2015/03/16
- Re: [Tinycc-devel] Predefined macro identifying TinyC?,
Ben Bacarisse <=
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Ramsay Jones, 2015/03/16
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Martin Guy, 2015/03/16
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Sergey Korshunoff, 2015/03/19
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Sergey Korshunoff, 2015/03/20
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Sergey Korshunoff, 2015/03/23
- Re: [Tinycc-devel] Predefined macro identifying TinyC?, Martin Guy, 2015/03/23