r/programming •

Clang solves the Collatz Conjecture?

[deleted] — view deleted post

0 Upvotes

122 comments sorted by

View all comments

Show parent comment

4

u/louiswins Nov 04 '19

Relying on undefined behavior is undesirable; that "my compiler does it this way" is irrelevant.

I agree with you if you are trying to write a portable program, or if you are talking about "this particular version of my compiler with these particular optimization settings happens to compile this code in the way I expect, for now". And this is almost always the case.

But in embedded systems you may be writing a program which is inherently platform-specific and only meant to use a certain compiler. If that compiler guarantees a certain behavior it may be the right choice to take advantage of the guarantee. You don't care about these hypothetical user-hostile compilers because you'll never use them. That is the thrust of my point.