All opt takes place by "as if" rule. Optimizations that violate that are not valid. Changing observable behavior is a bug
-
-
Replying to @RichFelker
Sure. Everything boils down to the question what "observable behavior" is.
1 reply 0 retweets 0 likes -
Replying to @ch3root @RichFelker
The amount of used memory is not part of observable behavior. In the same way as the execution time is not.
3 replies 0 retweets 0 likes -
Replying to @ch3root @RichFelker
Take "int main() { char s[10000000] = {0}; }". It segfaults with -O0 but not with -O3. Is this invalid optimization?
3 replies 0 retweets 0 likes -
Replying to @ch3root
No because the original program has UB (by overflowing stack). C std actually omits this but it's obvious.
2 replies 0 retweets 0 likes -
Replying to @RichFelker
I don't think you can label it as UB that easy. Whether something UB or not is decided based on the std alone and\
2 replies 0 retweets 0 likes -
Replying to @ch3root
I label SO as UB because the standard leaves it undefined by omission of any attempt to resolve contradictions around it.
1 reply 0 retweets 0 likes -
Replying to @RichFelker
Well, the standard doesn't mention stack at all. One way to look at it is that, hence, there are no restrictions on\
1 reply 0 retweets 0 likes -
Replying to @ch3root @RichFelker
a program related to stack. Thus, all implementation using stack are not conforming.
1 reply 0 retweets 0 likes -
Replying to @ch3root @RichFelker
But as you mentioned memory is limited in practice, stack or not. And there are similar problems with static vars.
2 replies 0 retweets 0 likes
You can ignore the word "stack". Problem is that the C std ignores inherent finitude of automatic storage.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.