This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: dewar at gnat dot com
- To: dewar at gnat dot com, paulus at samba dot org
- Cc: gcc at gcc dot gnu dot org, linux-kernel at vger dot kernel dot org,trini at kernel dot crashing dot org, velco at fadata dot bg
- Date: Sun, 6 Jan 2002 08:05:56 -0500 (EST)
- Subject: Re: [PATCH] C undefined behavior fix
<<* Given a pointer, I need a way to determine the address (as an int of
the appropriate size) that the CPU will present to the MMU when I
dereference that pointer.
>>
This is in general ill-defined, a compiler might generate code that sometimes
does byte access to a particular byte, anmd sometimes gets the entire word
in which the byte resides.
This is often a nasty issue, and is one of the few things in this area that
Ada does not properly address.
If you have a memory mapped byte, you really want a way of saying
"when I read this byte, do a byte read, it will not work to do a word read"
pragma Atomic in Ada (volatile gets close in C, but is not close enough) will
ensure a byte store in practice, but may not ensure byte reads.