6 ms·
I wonder how often a C program does something wrong because of a compiler bug versus a program bug. I’d think the former is extraordinarily rare for e.g. gcc. A
by runeks 5y ago
I wonder how often a C program does something wrong because of a compiler bug versus a program bug. I’d think the former is extraordinarily rare for e.g. gcc. Although, if you spend an hour studying every line of code (as is customary when writing safety-critical code), it’s possible you may arrive at a point where the primary source of bugs is the compiler.
However, for non safety-critical software I’d say buying a proven correct C compiler would be a waste of money.
- Agingcoder 5y agoCompiler bugs are not rare - it's just that most people never notice them.
- crubier 5y agoI was lucky enough to work with people working on CompCert in French public aerospace research labs. I remember a presentation in which they presented the number of bugs they found on other compilers (GCC, Clang, MSVC) while developing test cases and benchmarks, and it was surprisingly high! I don’t want to say any figures as I don’t remember it enough, but I think it was in the hundreds. And there are many horror stories on Hacker News of people being impacted by compiler bugs in prod on non-critical software, sometimes with significant financial impact. But yeah, not sure the price is worth it for non critical software in general.
- occamrazor 5y agoDid they fix or report the bugs upstream?
- archi42 5y agoThey're usually at least reported. At least that was the case for all the compiler-bug related papers I've read.
- crubier 5y agoYes I think they systematically reported it, and explained that their work was beneficial to all C compilers as a consequence. They did not fix them though, that would have needed a team 10x larger
- belter 5y agoDo you have a link to the presentation please ? All compilers have bugs, but I am interested in their comparison work in the context of CompCert
- rwmj 5y agoFedora gets the latest GCC release and we often run into bugs (which we file in the upstream tracker). Now to be fair most of them are not critical: the most common ones affect warnings where the compiler starts warning about code that we think is correct. But it does happen that we get more serious things. Several times I recall we've had to track down all packages that were compiled with a particular version of gcc/binutils and recompile them because we discovered a code-gen bug. In Fedora this is all low stakes but it wouldn't be if the software was deployed in a plane.
- alerighi 5y agoEspecially if you compile without optimisations. The optimisations can introduce bugs (although most of the times are related to undefined behaviour in the code), but without it is rare…
- lindig 5y agoCompiler bugs outside undefined behaviour are not rare; calling conventions as implemented in C compilers are complex and random testing found bugs in several compilers. However, the bugs are in parameter lists and types that are rare. https://lindig.github.io/papers/lindig-aadebug-2005.pdf https://lindig.github.io/papers/lindig-aadebug-2005.pdf