This is the mail archive of the
mailing list for the GCC project.
Re: auto const ints and pointer issue
Karen Shaeffer <firstname.lastname@example.org> 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
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.