News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by pjmlp on Friday May 21, 2021 @04:14AM (#27231626)
We had sanitizers since C exists, 1979 to be more exact.

"Although the first edition of K&R described most of the rules that brought C's type structure to its present form, many programs written in the older, more relaxed style persisted, and so did compilers that tolerated it. To encourage people to pay more attention to the official language rules, to detect legal but suspicious constructions, and to help find interface mismatches undetectable with simple mechanisms for separate compilation, Steve Johnson adapted his pcc compiler to produce lint [Johnson 79b], which scanned a set of files and remarked on dubious constructions. "

-- https://www.bell-labs.com/usr/dmr/www/chist.html

Re:Undefined behavior in C is a reading error by gpderetta on Friday May 21, 2021 @04:49AM (#27231818)
I was going to add "in open source compilers" to hedge my statement :).

That seems to be a static analysis tool though (which generally have not been great). Did it also inject runtime checks?

Re:Undefined behavior in C is a reading error by pjmlp on Friday May 21, 2021 @06:17AM (#27232251)
No, but still not even that gets the love it deserve.

And a famous commercial variant of it has been PC-lint from https://www.gimpel.com/.

Being available on open source compilers does little to change the culture, as per latest surveys only 11% of developers care to use any kind of tooling for improving their code quality in C and C++.

At CppCon a couple of years ago, only about 1% of the audience answered positively to Herb Sutters' question.

Re:Undefined behavior in C is a reading error by gpderetta on Friday May 21, 2021 @07:21AM (#27232663)
Those numbers are indeed a bit depressing.
Re:Undefined behavior in C is a reading error by pjmlp on Friday May 21, 2021 @09:02AM (#27233481)
Here is a recent survey, with a more positive number of about 37%, see question 10.

https://isocpp.org/files/papers/CppDevSurvey-2021-04-summary...