top | item 46137628

(no title)

abbeyj | 2 months ago

> We all know that strlen will return 5, but some compilers don't: 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.

discuss

order

abainbridge|2 months ago

Fair point. It doesn't do the optimization if you ask to optimize for size '/Os' either.