Very strange behavior from floor()

tmd3:
Nobody's shown that the details of the calculation were "optimized away." The only thing that's been shown is that the assembled program doesn't appear to call floor(). That's no error, bug, or quirk. The program doesn't call floor() because the compiler called it at compile time, along with multiplication and division, and embedded the result in the output code. There's no point in having the Arduino make those deterministic calculations every time it runs the program, when the compiler can make them once at compile time.

The programmer called a function, the compiler decided that function call was not needed... I completely agree that is not an error or a bug, which I have stated repeatedly... It is a quirk. It is a quirk because the machine decided that the programmer was inefficient and overrode the programmers directive. The compiler may be (and actually is correct); however, that doesn't alter the fact that a machine decided something without communicating to the person the 'change'. Now the reality is the issue is not AVR-GCC (at least not entirely), but an artifact (quirk) of the Arduino environment which seeks to protect programmers from the details. Which is why it is used by so many 'programmers' who don't have the experience to recognize problems like this.

I called it an undocumented feature for a reason. The documentation for the AVR-GCC leaves a lot to be desired... The quality of documentation is historically the biggest weakness of Open Source software. I personally don't think it is a problem, since the source code is available and nobody reads the manual anyway.