https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89561
bugsthecode at mail dot ru changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WONTFIX |--- --- Comment #6 from bugsthecode at mail dot ru --- (In reply to Richard Biener from comment #5) > Note that iff GCC could easily see "what you want" and see that some > undefined behavior rule contradicts this then from a QOI perspective GCC > already tries > to do what you want. What does "QOI" mean? And no, there is no perspective where GCC tries to do what I want, unless it's a perspective with brain damage. I'm not talking even about "legacy" option, an "error" option is unavailable as well. Only "generate-crap" is available, and happens more and more often. > The difficult thing is to detect what you want (from > inside generic analysis infrastructure). You literally have source code to see what I want. I wrote it there. Maybe not ideally and without bugs, but it is there. That's definitely not what user wants: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89218 That's miscompilation by gcc. User didn't request a crash there. And gcc-7 didn't generate such crap. But it's not recognized as regression because it's swept under the "we can generate any crap when undefined behaviour is encountered" crap. > For example GCC will not misoptimize > > int i; > > int main() { *(float *)&i = 0.0; return i; } > > even if it could (because type-based alias rules make the code undefined) > because it sees the must-alias. > Are you going to fix this case to generate crap as well in next gcc release? > That is, -fundefined-behavior=XYZ is impossible besides making all undefined > behavior implementation-defined (there are many options to individually > control > such thing already, like -fwrapv for example). Ok, there's huge amount of warning flags, but there's also -Wall and -Wextra to enable a lot of them at once. And there is -Werror to turn all of them into errors. Is there a global option for undefined behaviour configuration? None I know of. And what's so bad with changing undefined behaviour into implementation-defined behaviour? Better than potential CVE in my book. Why such option as -fwrapv even exists? Why not use safe defaults, and add options like -funsafe-fast-no-wrapv which would disable such behaviour but potentially make binary faster? -O2 used to be safe recommended optimization level, but now it generates a lot of crap. Maybe fast crap, but still a pile of vulnerable crashing crap.