This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: Richard Henderson <rth at redhat dot com>
- To: Dennis Ferguson <dennis at juniper dot net>
- Cc: Paul Mackerras <paulus at samba dot org>, Linus Torvalds <torvalds at transmeta dot com>, gcc at gcc dot gnu dot org
- Date: Sat, 5 Jan 2002 10:49:54 -0800
- Subject: Re: [PATCH] C undefined behavior fix
- References: <20020104153657.B17728@redhat.com> <200201051755.g05Hto684448@merlot.juniper.net>
On Sat, Jan 05, 2002 at 09:55:50AM -0800, Dennis Ferguson wrote:
> Sometimes I know what "foo" + 5 points to. If we're talking about
> the more general case of converting pointers to an integer representation
> of their bits, doing math on that, and converting the result back
> to a pointer ...
We're not talking about the general case. An object that the compiler
knows about (either global, file scope static, or on the stack) must be
involved.
> ... then both device drivers and memory allocators often
> depend on being able to do that fairly freely.
The heap is a different animal, since there we don't know what the
outer-most object really is, so we can't make the same inferences
that we can with compiler controlled objects.
In general, device drivers and memory managers should be safe.
r~