Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Whether his claims are warranted or not, his vitriol is still directed at the wrong place. If the behavior he claims is so easy to define is so easy, obvious, and beneficial, as he claims, he should just submit defect reports and get it fixed. Blaming the compiler authors is just silly (in the sense that it will never change anything, and is not effective)

As for folks "holding themselves to a higher standard", it's not really a sane thing to do here, because there is no universally agreed upon, or heck, even "precisely defined"set of "bad things" that they should not do. Depending who you ask, you will find differing answers on what people think should not be taken advantage of.

IE despite his claims, it's not even clear what this "higher standard" is supposed to look like.



His point as I understand it is that the people who would be doing the fixing are unlikely to agree that the defects he is reporting are actually defects, and that reporting them is therefore futile, absent a shift in consensus on the topic of undefined behavior. The paper exists in order to help promote that shift.


This is not an effective way, at all, to promote such a shift, of course. It's also not like this is the first paper. There are plenty of papers (he even cites a bunch) saying the same thing. So i'm not sure why anyone would think this would do much ...

Convince any of the 100+ vendors producing gcc forks to do it, have their customers sing their praises, and others will follow.

yelling about it on the internet is not likely to do much :)


> One of the things this person misses is a lot of these are undefined with the explicit goal to let compiler authors take advantage of them.

It doesn't look like it's missing it to me:

"C compiler maintainers also claim that these “optimizations” give speedups for other programs. However, that would require programmers to convert their C* programs to “C” first, a process which can produce worse code (Section 3), and more importantly, requires an effort that would be much more effective if directed at source-level optimizations."

The goal is to let compiler authors take advantage of undefined behavior for, among other things, performance. The counterclaim is that these goals are noble, but that letting compiler authors take advantage of undefined behavior as a means to achieve those goals is, unfortunately, counterproductive.

> Convince any of the 100+ vendors producing gcc forks to do it, have their customers sing their praises, and others will follow.

So... yell (positive things) on the internet?

> yelling about it on the internet is not likely to do much :)

Oh. Well, for what it's worth, I agree. As such, I spend my energy investing in staying the hell away from C when possible. I then yell positive things on the internet about alternatives for my own amusement. Still doesn't do much, but it does a little.


My reaction was to stop coding in C. You're safe from immediate irrelevance, but the alternatives keep getting better.


Anton is a compiler writer himself (part of the Gforth team, which I lead). We do submit bug reports. They get rejected as "invalid", on UB. It is pretty clear that the way we use GCC to implement Gforth is C* and not "C", we use extensions to GCC as source level optimizations. Without them, Gforth would be a factor 3-5 slower than it is now. We experience slowdowns in that order when we have to switch back to "C" instead of finding a workaround for that particular "optimization".

So sane behavior of the compiler is absolutely necessary to create fast programs. The tone reflects more than 10 years of frustration about "C" maintainers, and their inability do deal with the needs of their customers, and our long-term goal is to completely throw out C, writing our own code generator instead. It's going to give us another factor 2-5 (depending on the problem; some microbenchmarks might gain a factor 10) over the C*-based solution we have now. And, at the same time, we can forget about releasing a bug workaround patch for Gforth for every new GCC release, as it was the case for GCC 3.x and 4.x (GCC 5.x is better, some of the critics has been heard). This is feasible, as the number of popular architectures has decreased so far that a small team can support the remaining ones (which is essentially x64, ARM, and ARM64, with some variations within the family).

As a GNU project, we understand ourselves as customers of the other, very important GNU project, GCC, of which we, and almost everybody else in the GNU project, depend. If it's broken, it is too bad. And if the bug report process is broken due to the "UB=we can blow up your program" attitude, it's worse. If the competing comiler maintainers, clang, have the same attitude, we can't even switch.

We are also part of a language standard effort (Forth, of course), so we know how such a committee think; this is not different just because the language is different. What we don't understand is why the C standard has a lot of UB, and only little IB (implementation defined behavior). For example integer overflow: This is a very obvious candidate for IB, as the behavior of the underlying hardware defines integer overflow; usually as wrapv in two's complement, sometimes as trapv, but the other options like one's complement and such are non-existent. The result of such an operation is never "undefined", and as wrapv two's complement is the dominating implementation, it is pretty portable, as well.

Or how pointers look like (pointer comparison): You know how your pointers will look like when you implement a C compiler, so you can fully specify the behavior of pointer comparisons. It's IB, because segmented architectures like 8086 with their overlapping segments simply don't give reliable and fast results. But if you don't program for MS-DOS, you don't need to care: usually pointers are just register-sized integers pointing to a flat, non-segmented memory, and pointer comparison is just compiled to integer comparison.

Bottom line: If you don't understand what your underlying machine does, and how your code generator translates statements to instructions, and therefore you think that x-1>x never can become true, you shouldn't be writing compilers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: