Live data from Hacker News

“It is never a compiler error”

blog.plover.com

181–190 of 280 posts

Re: “It is never a compiler error”

#181
post #96

Earlier quoted context omitted.

> BTW, what you're talking about isn't a compiler error. Neither was the blog post: > [ Addendum 20171113: Yes, yes, I know sort() is in the library, not in the compiler. I am using "compiler error" as a synecdoche for "system software error". ]

That's not even what that word means.

Yes it is. A "synecdoche" is where you use a part to refer to the whole (or vice versa).

Re: “It is never a compiler error”

#182
post #129

"The compiler did not have a bug. The compiler never had a bug. The bug was always in the programmer's code and usually in their understanding of the language... It was caused by a misunderstanding of the way arguments to unprototyped functions were automatically promoted..." - I'd say the bug is neither in the compiler nor in their understanding of the language but in the language itself then. Why on Earth do we nee…

> Why on Earth do we need a language that [...] Have someone sit down with you and explain how slow computers were in the 1970's. C won because it could be efficiently implemented on everything, produce better code than pretty much anything else, and still produce effective software quickly. And everything after that is a network effect because of all the inherited C. Your complaint has been repeated ad nauseum by li…

Mainframes had bounds checks. It didn't cost much, but C omitted them. Some of the undefined behavior in C particularly around accesses and overflow could be changed to implementation defined to fix some of the more footgunny parts. Until C 99 C could not vectorize nearly as much as Fortran. C won because of Unix network effects and the PDP, not because it was that good a choice.

Re: “It is never a compiler error”

#184
At my previous job a colleague showed me some C++ code and asked if I could help him spot the issue. I looked at it and said it looked fine. He ran the program and it crashed.

We ended up staying late in order to try to find a minimal reproducible example. We finally managed and found that the cause was a basic trigonometric function in the standard library giving the wrong result.

At first, we couldn't believe it. Then we googled the issue and found a bug report about the intrinsic version of that function not working properly. With Microsoft confirming that it didn't and that they weren't looking to fix it. We disabled intrinsics in that section of the code and the original code worked as intended.

Re: “It is never a compiler error”

#185
Back when i wrote software for GSM mobile phones (2000'ish), we spotted several compiler errors in our "Infineon E-Gold" C compiler.

If you declared something like :

    int a = 1 + 2 + 3;
The result would simply be "a=3". Turned out the compiler threw out any argument besides the first two.

Another error would be the compiler failing to increment the segment pointer (16 bit platform), and the offset pointer simply wrapped around. This didn't show itself until we added a new 120x90 pixel four color display, meaning our display shadow buffer grew to a staggering 20 KiB, and depending on the build, the display buffer would become corrupted.

Certification for GSM compilers is expensive, so we just learned to work around it, i.e. we reimplemented our stdlib memcpy, memmove, strcpy, etc functions in assembler.

Re: “It is never a compiler error”

#188

Sadly, I've lost count of how many compiler bugs I've tripped over through the years. Often it's compiler crashes -- those are usually easy to get fixed, especially when (as tends to be the case with LLVM) they are caused by assertions failing -- but I've also tripped over compiler hangs (there's a variable in the tarsnap code with an utterly bogus volatile specifier in order to avoid the problematic optimization on…

If you’re the kind of programmer who is likely to find compiler errors, you probably know who you are. For 99% of programmers, the chances that you have discovered one is small.

> If you’re the kind of programmer who is likely to find compiler errors, you probably know who you are.

I'm one of those that routinely find a bug in a library during the very first use of its API. Every "quick weekend project" turns into "let's learn the build system of this library and send a patch/bug report to the maintainer".

Does anybody know how can I turn this annoying superpower of mine into a job that is not basic Q/A?

Re: “It is never a compiler error”

#189
post #180

When I was just getting into the industry, I was offered a job from a team at IBM, working on some OS or other whose name I forgot. I was chatting with the head developer about the workflow. He told me that, as the OS was written in a custom programming language, and the OS was the only program ever written in this programming languages, they found that roughly 50% of the bugs they encountered were in the OS code, an…

If you hadn't mentioned IBM, I would've guess this was Bell Labs, Unix and C.

IBM has built several operating systems and programming languages and compilers over the years. Probably more than Bell Labs, actually. It's not so surprising.

Re: “It is never a compiler error”

#190
> The sort() function was using a bubble sort. (This is of course a bad choice, and I think the maintainers plan to replace it.)

There are some valid use cases for Bubble Sort for small and almost sorted arrays (although Array.prototype.sort sounds like a very general solution, which I suppose is not a good idea). I've seen this in JavaScriptCore where they use Cocktail Sort (a variant of Bubble Sort) for sorting in some situations. They also added some performance numbers and explanation in [1] that show that it's faster than e.g. std::stable_sort. I actually tried to write an Insertion Set (which is supposed to be better than Bubble Sort), but couldn't get it to perform better than their Cocktail Sort implementation.

[1] https://github.com/WebKit/webkit/blob/master/Source/WTF/wtf/...

Post reply on HN