2 ms·
> Are you really saying that no optimizations are allowed once the compiler notices UB? My statement is specific to how data is shared across multiple threads
by bluGill 3y ago
> Are you really saying that no optimizations are allowed once the compiler notices UB?
My statement is specific to how data is shared across multiple threads and does not generalize to any other situation, such as the one you presented. When threads are in play a compiler typically cannot know if there is UB or not (since the access is often done across different translations units).