In C++, compiler optimization may produce "unexpected" program behaviors by taking advantage of undefined behaviors in a program, like signed integer overflows and dereferencing null pointers. It is important to test a program in release build if a release build is used in the production.
In C#, undefined behaviors are rare. Are there more reasons to test a program in release build before using in production other than
- Unsafe code
- Multithread timing
- Debug/release mode enabled/disabled code (e.g. #if)
Can optimization produce different program behaviors like C++?