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: auto const ints and pointer issue


Karen Shaeffer <shaeffer@neuralscape.com> writes:

> I see your point. My sticking point is that the process is actually
> running on a physical machine. And the addresses, although virtual,
> do translate to a unique physical memory location. And, the value
> stored in that location cannot be 0 and 5 at the same time. And my
> comments were addressing that the undefined behavior of this illegal
> assignment should not violate the physical constraints of what is
> actually stored in that physical address. I would be OK with -1
> being stored in there, or zero, or whatever, or the process crashing,
> but what I see is not congruent with my thinking about the limits
> of the compiled binary at run-time. Obviously I need to rethink those
> assumptions.

Undefined behaviour is undefined behaviour.  You can not predict what
the compiler do.  

> the value
> stored in that location cannot be 0 and 5 at the same time.

No, but in the presence of undefined behaviour the compiler is
perfectly free to assume that that is in fact the case.  This isn't
intentional, of course; it just falls out of other optimizations.

Ian


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