Re: Prioritize Performance over Correctness

Johann 'Myrkraverk' Oskarsson <[email protected]> Tue, 28 Jul 2026 08:14:04 +0800
Newsgroups comp.lang.c,alt.ascii-art
Organization Watcom Pro Ltd.
Message-ID <[email protected]>
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