Remix.run Logo
aw1621107 2 days ago

> Also, the Linux kernel developers turned off strict aliasing in the C compilers they use, because they found strict aliasing too difficult.

I'm not sure "they found strict aliasing too difficult" is an entirely correct characterization? From this rather (in)famous email from Linus [0]:

    The fact is, using a union to do type punning is the traditional AND
    STANDARD way to do type punning in gcc. In fact, it is the
    *documented* way to do it for gcc, when you are a f*cking moron and
    use "-fstrict-aliasing" and need to undo the braindamage that that
    piece of garbage C standard imposes.

    [snip]

    This is why we use -fwrapv, -fno-strict-aliasing etc. The standard
    simply is not *important*, when it is in direct conflict with reality
    and reliable code generation.

    The *fact* is that gcc documents type punning through unions as the
    "right way". You may disagree with that, but putting some theoretical
    standards language over the *explicit* and long-time documentation of
    the main compiler we use is pure and utter bullshit.
[0]: https://lkml.org/lkml/2018/6/5/769
wordisside 2 days ago | parent [-]

[flagged]