3 ms·
No they are not. When your program invoke UB, it is a bug in your program, and not in the compiler. The compiler author are helping you with things like -fsani
by ogoffart 7y ago
No they are not.
When your program invoke UB, it is a bug in your program, and not in the compiler.
The compiler author are helping you with things like -fsanitize=undefined. Or even lets you define some behavior which is normaly undefined with things like -fwrapv, -fno-strict-aliasing, -fno-delete-null-pointer-checks
But you are asking the compiler to optimize your program, if you give an invalid program to optimize, you get an invalid result. There is no bug there.