Re:It Is Never a Compiler Bug Until It Is
by hyperman1 on Wednesday September 30, 2020 @08:34AM
(#24638097)
Long ago, I bought the MIX C compiler for DOS. It had a tendency to miscompile basic things like the ++ operator. Lost hours of my life on it.
One day I found out about DJGPP, and even if the download cost a fortune in phone time, life was so much better.
Now the C reference book included with MIX C turned out to be much better than the compiler itself, and served me well for a decade.
Re:It Is Never a Compiler Bug Until It Is
by widforss on Wednesday September 30, 2020 @08:08AM
(#24637892)
The first example sounds like a bug that could sneak in anywhere, but the second one makes me question how they laid out the compiler architecture.
Did they write a special expression parser just for declarations? I mean, this shouldn't be possible if there was just one expression parser?
Re:It Is Never a Compiler Bug Until It Is
by devthrowawy on Wednesday September 30, 2020 @10:49AM
(#24639281)
Probably more to do with compile time static expression evaluation (optimization) than parsing. Seems like it's not actually recursing down, just evaluating the root.
Re:It Is Never a Compiler Bug Until It Is
by phaedrus on Wednesday September 30, 2020 @12:30PM
(#24640539)
That could be, but my first thought was it's only compiling it to a single assembly instruction (which can only have two operands). Or it generates ADD instructions using a succession of registers or stack locations, but the initialization code blindly assumes the result is in the first register or stack location.
At the time we were working on a new "feature phone" with a 160x120 pixel display in 4 shades of grey, which was a huge upgrade compared to our previous models. Another feature was full screen images for the various applications, and we'd been implementing is into the software and testing it for weeks without problem. After the development cycle came to an end, our release team created a new software release and sent it to our test department, which almost instantly reported graphical errors back to us. We tested the software image on our own handsets, and half the screen was "garbage".
We spent weeks looking over the merged code, as well as debugging pointers code and found nothing. It wasn't until we were stepping through the paint code with a Lauterbach debugger that we noticed something was "off" with a pointer.
The platform was a 16 bit platform and memory was addressed using a page pointer pointing to a 64kb memory page. When we traversed the bitmaps fate would have it that this particular bitmap, in this particular build, was split between two pages, and when incrementing a pointer beyond the page limit, instead of incrementing the page pointer, it simply just overflowed and started from the beginning of the current page.
Another interesting bug we chased in the compiler was it's inability to add more than 2 variables in initial assignment.
i.e.
That took a while to figure out.