| It is undefined behaviour if I write GCC --hlep Does that mean it's acceptable for GCC to reformat my hard drive? Just because something is UD doesn't give anyone a license to do crazy things. If I misspell --help I expect the program to do something reasonable. If I invoke UD I still expect the program to do something reasonable. Removing checks for an overflow because overflows 'can't happen' is just crazy. UD is supposed to allow C to be implemented on different architectures if you don't know whether it will overflow to INT_MIN it makes sense to leave the implementation open. If I, the user knows what happens when an int overflows then I should be able to make use of that and guard against it myself. A compiler undermining that is a bug and user hostile. |
No, it's not, and I don't know why you'd think so. UB is a concept applying to C programs, not GCC invocations.
> UD is supposed to allow C to be implemented on different architectures if you don't know whether it will overflow to INT_MIN it makes sense to leave the implementation open. If I, the user knows what happens when an int overflows then I should be able to make use of that and guard against it myself.
I think you're confusing UB with unspecified and implementation defined behavior. It's fine if you think something shouldn't be UB, but you have to go lobbying the C standard for that. Compiler writers aren't to blame here.