Re:GCC undefined behaviors are getting wild
by throwaway81523 on Monday November 28, 2022 @05:31AM
(#33771890)
Everyone wants that, but when asked for a concrete specification they seem to realize that it is harder than it sounds. Look for John Regehr's blog entries about "Friendly C" for an example. The basic problem here is that C is a terrible language. We shouldjust give up on it by now.
Re:GCC undefined behaviors are getting wild
by sanxiyn on Monday November 28, 2022 @07:15AM
(#33772674)
I provided the concrete specification. What is hard about it? Get it done already.
Re:GCC undefined behaviors are getting wild
by Asooka on Monday November 28, 2022 @06:05AM
(#33772135)
You can get 99% of the way there with -fno-delete-null-pointer-checks -fno-strict-aliasing -fwrapv . Pretty much every program I've worked on uses those flags, as that's the only way to keep your sanity.
Re:GCC undefined behaviors are getting wild
by gpderetta on Monday November 28, 2022 @06:40AM
(#33772382)
-fdwim
Next generation of AI powered compilers will try to interpret code at a more abstract level and infer what the programmer was thinking even if they wrote the wrong thing.
Everything will work perfectly 100% of the time.
Re:GCC undefined behaviors are getting wild
by sanxiyn on Monday November 28, 2022 @07:12AM
(#33772628)
This already exists. Don't write standard C, avoid it like the plague. Compile with -fno-strict-overflow -fno-strict-aliasing -fno-delete-null-pointer-checks, like I do, like Linux kernel does, and like everyone sane does.
Re:GCC undefined behaviors are getting wild
by NohatCoder on Monday November 28, 2022 @08:03AM
(#33773102)
No, not everyone sane. Rather everyone sane who has been bitten enough by these issues to use such rules. Everyone starts out at -O2, because understanding all the other flags and their implications is super difficult. As long as the insane setting is default, a large percentage of programmers will be using the insane setting. Arguing that they should have flagged their compilations otherwise is about as useful as pointing out that people shouldn't write UB in the first place.
Then they can add a #pragma optimize(assumes=no-int-overflow, whatever, etc) to precisely add optimizations when needed and you 'know' its safe.