13 ms·
> We all know that strlen will return 5, but some compilers don't: https://godbolt.org/z/M7x5qraE6 https://godbolt.org/z/M7x5qraE6 I feel like it is unfair to
by abbeyj 10mo ago
> We all know that strlen will return 5, but some compilers don't: https://godbolt.org/z/M7x5qraE6 https://godbolt.org/z/M7x5qraE6
I feel like it is unfair to blame the compiler when you've explicitly asked for `/O1`. If you change this to `/O2` or `/Ox` then MSVC will optimize this into a constant 5, proving that it does "know" that strlen will return 5 in this case.
- abainbridge 10mo agoFair point. It doesn't do the optimization if you ask to optimize for size '/Os' either.