Bruce Stephens wrote:
Ulf Ochsenfahrt <[EMAIL PROTECTED]> writes:

[...]

If there is an invalid pointer in the non-empty list, the program
can crash.

It can crash, but this is presumably in the realm of undefined
behaviour, so arbitrary things are permitted to happen.

If the compiler optimizes (i.e. removes) the list traversal, the
program doesn't crash. Thus, the optimization would change the
runtime behavior of the program.

Probably, but I think that's a permitted change.

What about inifinite loops? The linked list could also loop back to itself.

I'd guess a bug report along those lines ("your optimizer caused my
program not to crash!") would be unlikely to be given a high priority.

Compiler writers are usually very conservative. I would guess that 'the optimizer makes the program behave differently' is a serious enough issue.

An implementation with an O(1) implementation of size() would
presumably also not crash at that point either.

True. But the compiler can't know that. The compiler only sees the code, it doesn't know what it's supposed to do.

Cheers,

-- Ulf


_______________________________________________
Monotone-devel mailing list
Monotone-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monotone-devel

Reply via email to