Re: Bounds checked arrays
From: Martin Dickopp (expires-2004-03-31_at_zero-based.org)
Date: 02/15/04
- Next message: Mark McIntyre: "Re: A C tutorial"
- Previous message: Mark McIntyre: "Re: A C tutorial"
- In reply to: jacob navia: "Bounds checked arrays"
- Next in thread: jacob navia: "Re: Bounds checked arrays"
- Reply: jacob navia: "Re: Bounds checked arrays"
- Reply: Phil Tregoning: "Re: Bounds checked arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 15 Feb 2004 00:27:03 +0100
"jacob navia" <jacob@jacob.remcomp.fr> writes:
> As everybody knows, the C language lacks a way of specifying bounds
> checked arrays.
Yes, but I don't think anything in the C standard /forbits/ an
implementation to check array bounds. From the point of view of the
standard, accessing an out of bounds array element causes undefined
behavior, so the implementation is free to (e.g.) terminate the program.
<OT>
FWIW, there is or was an attempt to implement bounds checking in the
GNU C compiler. I don't know what the current state is.
</OT>
> It would be useful then, if we introduced into C
>
> #pragma STDC bounds_checking(ON/OFF)
I disagree. While I would find bounds checking very useful, I consider
it a quality of implementation issue, not something which should be
standardized. Remember that there are also C compilers for embedded
devices, which often operate under severe memory constraints (the
devices, not the compilers) and cannot (and need not) afford the
additional bounds checking overhead. Mandatory bounds checking in the
standard would force these compilers to implement it nevertheless.
Martin
- Next message: Mark McIntyre: "Re: A C tutorial"
- Previous message: Mark McIntyre: "Re: A C tutorial"
- In reply to: jacob navia: "Bounds checked arrays"
- Next in thread: jacob navia: "Re: Bounds checked arrays"
- Reply: jacob navia: "Re: Bounds checked arrays"
- Reply: Phil Tregoning: "Re: Bounds checked arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]