Re: A basic (?) problem with addresses (gcc)



On 2010-12-17, BartC <bc@xxxxxxxxxx> wrote:
"Seebs" <usenet-nospam@xxxxxxxxx> wrote in message
news:slrnigngqu.a6p.usenet-nospam@xxxxxxxxxxxxxxxxxx
On 2010-12-17, BartC <bc@xxxxxxxxxx> wrote:
I'm just
suggesting something less cumbersome and restrictive than unions.

It sounds very cumbersome and restrictive from the standpoint of an
implementor trying to decide whether to generate extremely slow memory
reads from an object that in theory shouldn't be getting modified.

This is the original code:

I was talking about your more generic equivalence with arbitrary
overlap but...

If it has been written to (initialising y to 0 would have been better), then
how did that rogue value get there? What were they trying to optimise?

The general case is this:

int foo(int *a, float *b) {
float x = *b;
*a = 3;
x = *b;
}

Can the second read from *b be optimized away? In C, yes. In your
hypothesized language, no.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@xxxxxxxxx
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
.