[TUHS] I can't drive 55: "GOTO considered harmful" 55th anniversary

Dan Cross crossd at gmail.com
Sun Mar 12 21:40:11 AEST 2023


On Sun, Mar 12, 2023, 3:39 AM Anthony Martin <ality at pbrane.org> wrote:

> Dan Cross <crossd at gmail.com> once said:
> > I'm told that the plan9 C compilers were callee-save in part to keep
> > these state labels svelte.
>
> The Plan 9 compilers are caller-save. That means the labels only have
> to contain pc and sp.


Indeed. I typo-ed but meant caller-save; it wouldn't be very svelte if it
were the other way around. ;-)


Waserror works well except for one small issue
> involving whether or not the compiler decides to store a value to a
> non-volatile, non-pointer variable when the value would not be used
> after a function call. As in:
>
>         int a;
>         a = 1;
>         if(waserror()){ /* ... */ }
>         a = 2;
>         a = foo(a);
>
> The waserror branch may see a == 1 if foo errors.
>
> Ken's compilers are great, though. They don't engage in antisocial
> optimizations based on dubious notions of undefined behavior. I'd
> prefer my compiler to not elide explicit null checks or loads and
> stores from a pointer.


It is certainly a shame that modern compiler writers have become
essentially hostile to programmers in their pursuit of ever more aggressive
optimizations based on rigid readings of the standard, common sense be
damned.

As for the plan9 C _language_, in the late 80s, it was arguably an
improvement over what ANSI put out. Nowadays, however, I think the inverse
is true. *Shrug*

        - Dan C.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20230312/7435e021/attachment.htm>


More information about the TUHS mailing list