This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
On Mon, 2007-10-29 at 11:57 +0000, Darryl Miles wrote:
> This then leads into the question. Is a pointer allowed to be invalid.
A variable of type X need not contain an X in C, however the
effect of any operation including assignment, copying,
or passing is undefined if the value isn't valid.
Valid pointers are NULL or a pointer to, into, or one
past the end of any individual storage block.
However most architectures/ABI's work fine copying invalid
pointers.
The rule is partly due to Intel segmented memory,
allowing pointers to be passed in Segment:offset register
pairs, which in protected mode requires a valid
segment descriptor.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net