This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Serious code generation/optimisation bug (I think)



Laurent GUERBY wrote:
> >> Just curious: is there a "portable" way to read from memory
> >> address zero in C code? "portable" here means likely to work
> >> on most compilers without exotic compile flags in 2009.

Florian Weimer wrote:
> > No, C hasn't got a notion of addresses.  The situation is likely to
> > get even more extreme, not less (in the sense that C continues to be
> > perceived as a low-level language, but current implementations really
> > aren't).

On Tue, Jan 27, 2009 at 04:29:34PM -0800, Robert Dewar wrote:
> Laurent asked a pragmatic question, you answered with a language
> lawyer hat on, which is really not so helpful. In fact if you cast
> a value of zero which the compiler cannot see is zero, and then
> dereference, this will meet Laurent's criterion.

I would think that one clean way to do it, for an embedded system,
is to define a struct that contains the fields that should go on the
zero-page, starting at address zero, and make that struct a global
that lives in a special section.  This section can then be mapped
to the desired location (zero) by the linker.  Since the compiler
wouldn't see it as being at address zero, you'd get correct code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]