• Re: Prioritize Performance over Correctness

    From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Tuesday, July 28, 2026 08:14:04
    On 28/07/2026 3:58 AM, Keith Thompson wrote:


    You'd have to create a compiler, or modify an existing one, to use a
    non-zero representation for null pointers. That's hardly "trivial".
    (For example, default initialization for static objects could no
    longer just zero the target object.)

    __ .----.__
    .________________________________________.
    -' `/(#)#(#) `- . o O ( I tend to assume people are more
    capable )
    ` (#)#(#) \ ___ ^( than they actually are, because
    it )^^
    __( \ ,,,/ `. ``. ( makes them either feel better,
    or some- )
    / \ \,-/ | \ ( times they rise to the challenge! )^^^^^^
    | `-- ( ( /__ ( ^^^( )^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ` ( `---\ `---._` ( } (^^
    ^^)______________________________.
    | | \ `----._`.`. .' ( For instance, this is an old
    ASCII art )
    . ( `-) \ `. )) ) | ( horror I made several years ago.
    )^^^
    / \ / / ) / { ( I got semi-famous for my
    collection )
    / \ / ( | ( ( of non-trivial ASCII art.
    )^^^^^^^^^^
    / ,\ /\\\ ( |_ \ ( And I made all of it by hand,
    including )
    / /\( ) / .`\\\ ^^( this thought bubble.
    )^^^^^^^^^^^^^^
    \\/ \ .-' | | -_ ^^^^^^^^^^^^^^^^^^^^^^^
    \ .'___( ) \ `-.
    -' \/\___\\__\

    /** Do you ever mix C and ASCII art? **/

    int main( int _, char *o[] ) { return _^( int ) main <3 ; }



    I don't think there are any modern C compilers that don't use
    all-bits-zero for null pointers. Other representations are of
    course valid, but tend not to be worth the trouble.

    I wouldn't be terribly surprised if a future standard mandated
    all-bits-zero for null pointers -- or if it didn't.


    I think more of it like an arm-chair thought exercise. The issue
    isn't the bit pattern at all, but how you're going to treat conversion
    to integers. Especially in this context,

    if ( p ) { ... }

    a 64bit p with the pattern 0x..00000000 isn't supposed to be false,
    when truncated to an integer. If I remember the standard(s)
    correctly, p here is supposed to "devolve" into either 1 or 0 in a
    boolean context. I'd believe comparing to zero, and use the Z flag is
    normal in x64, and in MIPS64, direct comparison to $zero is probably
    the most normal way to go about it.
    I forgot the actual instructions in both cases. They're easy to
    look up anyway.

    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Tuesday, July 28, 2026 20:18:36
    On 28/07/2026 8:02 PM, bart wrote:
    On 28/07/2026 12:21, Johann 'Myrkraverk' Oskarsson wrote:
    On 28/07/2026 6:22 PM, Keith Thompson wrote:
    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> writes:
    On 28/07/2026 8:59 AM, Keith Thompson wrote:

    Your ASCII art has nothing to do with the current discussion (and
    didn't even display correctly due to line wrapping).˙ I've dropped
    the cross-post to alt.ascii-art.˙ Can you please try to focus?

    Nope.˙ You've absolutely demonstrated that you have no idea what
    is involved in the internals of a C compiler.

    You don't seem to have much idea either.


    ˙ What you're trying
    to describe is just hogwash and balderdash when it comes to the
    real world nitty gritty of implementing a compiler.

    Now stay out of my compiler discussion, you're not wanted here!

    Perhaps the rest of the group would be interested in knowing just
    what I got so badly wrong.


    I'll summarize it as: You think I care what the C standard documents
    say.˙ I don't.

    I care how it's implemented.˙ You don't.

    This is what you wrote:

    "I think more of it like an arm-chair thought exercise.˙ The issue
    isn't the bit pattern at all, but how you're going to treat conversion
    to integers.˙ Especially in this context,

    ˙ if ( p ) { ... }

    a 64bit p with the pattern 0x..00000000 isn't supposed to be false,
    when truncated to an integer...."

    You don't say what type 'p' is, but I assume it is a pointer.

    How a compiler implements this depends partly on what the language says,
    for example:

    ˙ Scalar type˙ Value˙˙ True when

    ˙˙ integer˙˙˙˙˙ i˙˙˙˙˙ i != 0
    ˙˙ float˙˙˙˙˙˙˙ x˙˙˙˙˙ x != 0.0˙˙˙˙ (-0.0 may need considering)
    ˙˙ pointer˙˙˙˙˙ p˙˙˙˙˙ p != NULL

    Whether NULL is all-bits-zero depends on the implementation, but I think
    it it more platform-dependent rather than left to individual compilers.

    Since in that case code from different compilers would be incompatible,
    and calling into external libraries would be problematical.

    In any case, there is no conversion to int involved; it is just has to implement that comparison by whatever means works.


    Indeed, and if you read the snippet you so thoughtfully cut off, you'd
    have realized that's exactly how I think about it, in terms of compiler internals. Now, of course, you being an expert in twisting other
    people's expertise, you must be a journalist? Do you perhaps write for
    VICE? I got my name into a VICE article once, for not being involved
    at all. That was comforting. Now I feel like I'm just as important
    as UBS.

    On the other hand, to the programmer, especially those not who have not
    and never will read the C language standard, it does look like the p
    pointer is "truncated" to an integer valued 0 or 1, in boolean context.

    And as I told Keith, I don't care how the language standard words
    things. I care how the compiler is implemented.

    .________________________.
    ,-'""`-. ( )
    ; : o 0 ( I also added some more old )
    : : ( ASCII art, and re-added )
    : (_) (_) ; ( alt.ascii-art for cross )
    ` '` ' ^^( posting purposes! )^^
    :`++++'; ^(._______________.)
    ``..'' /mv/



    Happy writing articles for VICE!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven M. O'Neill@3:633/10 to All on Tuesday, July 28, 2026 21:35:55
    Pardon the top-posting. Just wanted to let you know that this
    didn't display well on my particular setup, as my newsreading
    software is set up to wrap at around 80 columns. IIRC this is
    (or used to be at least) the accepted limit for line lengths.

    Full message quoted below, which should explain what I mean.

    Here's what 80 columns look like: 12345678901234567890123456789012345678901234567890123456789012345678901234567890

    HTH. Also, I changed the newsgroups to just alt.ascii-art

    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:
    On 28/07/2026 3:58 AM, Keith Thompson wrote:


    You'd have to create a compiler, or modify an existing one, to use a
    non-zero representation for null pointers. That's hardly "trivial".
    (For example, default initialization for static objects could no
    longer just zero the target object.)

    __ .----.__
    .________________________________________.
    -' `/(#)#(#) `- . o O ( I tend to assume people are more
    capable )
    ` (#)#(#) \ ___ ^( than they actually are, because
    it )^^
    __( \ ,,,/ `. ``. ( makes them either feel better,
    or some- )
    / \ \,-/ | \ ( times they rise to the challenge!
    )^^^^^^
    | `-- ( ( /__ ( ^^^( )^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ` ( `---\ `---._` ( } (^^
    ^^)______________________________.
    | | \ `----._`.`. .' ( For instance, this is an old
    ASCII art )
    . ( `-) \ `. )) ) | ( horror I made several years ago.
    )^^^
    / \ / / ) / { ( I got semi-famous for my
    collection )
    / \ / ( | ( ( of non-trivial ASCII art.
    )^^^^^^^^^^
    / ,\ /\\\ ( |_ \ ( And I made all of it by hand,
    including )
    / /\( ) / .`\\\ ^^( this thought bubble.
    )^^^^^^^^^^^^^^
    \\/ \ .-' | | -_ ^^^^^^^^^^^^^^^^^^^^^^^
    \ .'___( ) \ `-.
    -' \/\___\\__\

    /** Do you ever mix C and ASCII art? **/

    int main( int _, char *o[] ) { return _^( int ) main <3 ; }



    I don't think there are any modern C compilers that don't use
    all-bits-zero for null pointers. Other representations are of
    course valid, but tend not to be worth the trouble.

    I wouldn't be terribly surprised if a future standard mandated
    all-bits-zero for null pointers -- or if it didn't.


    I think more of it like an arm-chair thought exercise. The issue
    isn't the bit pattern at all, but how you're going to treat conversion
    to integers. Especially in this context,

    if ( p ) { ... }

    a 64bit p with the pattern 0x..00000000 isn't supposed to be false,
    when truncated to an integer. If I remember the standard(s)
    correctly, p here is supposed to "devolve" into either 1 or 0 in a
    boolean context. I'd believe comparing to zero, and use the Z flag is
    normal in x64, and in MIPS64, direct comparison to $zero is probably
    the most normal way to go about it.
    I forgot the actual instructions in both cases. They're easy to
    look up anyway.

    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com


    --
    Steven O'Neill steveo@panix.com
    Brooklyn, NY http://www.panix.com/~steveo

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Wednesday, July 29, 2026 05:54:58
    On 29/07/2026 5:35 AM, Steven M. O'Neill wrote:
    Pardon the top-posting. Just wanted to let you know that this
    didn't display well on my particular setup, as my newsreading
    software is set up to wrap at around 80 columns. IIRC this is
    (or used to be at least) the accepted limit for line lengths.

    Apologies. I did this in my text editor, and neglected to notice
    the longest line is 81 columns. My editor says the end of the line
    is at 80, but starts the column count at zero. I'm unsure if that
    should be counted as 80 columns, or 81. Is the following any better
    for you? The original displays correctly for me, in my newsreader.

    __ .----.__ .________________________________________.
    -' `/(#)#(#) `- . o O ( I tend to assume people are more
    capable )
    ` (#)#(#) \ ___ ^( than they actually are, because it )^^
    __( \ ,,,/ `. ``. ( makes them either feel better, or
    some- )
    / \ \,-/ | \ ( times they rise to the challenge! )^^^^^^
    | `-- ( ( /__ ( ^^^( )^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ` ( `---\ `---._` ( } (^^
    ^^)______________________________.
    | | \ `----._`.`. .' ( For instance, this is an old ASCII
    art )
    . ( `-) \ `. )) ) | ( horror I made several years ago.
    )^^^
    / \ / / ) / { ( I got semi-famous for my
    collection )
    / \ / ( | ( ( of non-trivial ASCII art. )^^^^^^^^^^
    / ,\ /\\\ ( |_ \ ( And I made all of it by hand,
    including )
    / /\( ) / .`\\\ ^^( this thought bubble.
    )^^^^^^^^^^^^^^
    \\/ \ .-' | | -_ ^^^^^^^^^^^^^^^^^^^^^^^
    \ .'___( ) \ `-.
    -' \/\___\\__\

    My newsreader garbleds the paste in the newsreader-editor, but appears
    to post correctly anyway. You can also see the image sans thought
    bubble at

    https://asciiart.website/search.php?q=myrkraverk&sort_by=random

    and my own website.

    Cross posting to comp.lang.c as well, for Keith.


    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven M. O'Neill@3:633/10 to All on Friday, July 31, 2026 20:34:51
    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:
    Apologies. I did this in my text editor, and neglected to notice
    the longest line is 81 columns. My editor says the end of the line
    is at 80, but starts the column count at zero. I'm unsure if that
    should be counted as 80 columns, or 81. Is the following any better
    for you? The original displays correctly for me, in my newsreader.

    Still wrapping. Here, I can remove the wrappy bits.
    (the text makes less sense now :)

    __ .----.__ .________________________________________.
    -' `/(#)#(#) `- . o O ( I tend to assume people are more
    ` (#)#(#) \ ___ ^( than they actually are, because it )^^
    __( \ ,,,/ `. ``. ( makes them either feel better, or
    / \ \,-/ | \ ( times they rise to the challenge!
    | `-- ( ( /__ ( ^^^( )^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ` ( `---\ `---._` ( } (^^
    | | \ `----._`.`. .' ( For instance, this is an old ASCII
    . ( `-) \ `. )) ) | ( horror I made several years ago.
    / \ / / ) / { ( I got semi-famous for my
    / \ / ( | ( ( of non-trivial ASCII art. )^^^^^^^^^^
    / ,\ /\\\ ( |_ \ ( And I made all of it by hand,
    / /\( ) / .`\\\ ^^( this thought bubble.
    \\/ \ .-' | | -_ ^^^^^^^^^^^^^^^^^^^^^^^
    \ .'___( ) \ `-.
    -' \/\___\\__\

    Nice :D

    --
    Steven O'Neill steveo@panix.com
    Brooklyn, NY http://www.panix.com/~steveo

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)