News for hackers. Stuff that matters.
Re:Raku: A Language for Gremlins by trealira on Tuesday August 08, 2023 @12:10PM (#37051251)
> Do you mean unsigned branches? JB/JBE/JA/JAE instead of JL/JLE/JG/JGE?

Yeah, that's what I meant. Thanks for speaking more clearly.

> Are there actually code patterns where it's preferable to just JE/JNE?

That's a good point, and sidesteps the issue of pointer signedness.

I think sometimes JE / JNE isn't enough. For example, if you want to process a buffer in reverse order using pointer arithmetic:

  /* p starts off one past the end of the buffer */
  char *p = buffer + bufsize;
  while (--p >= buffer) {
      /* ... */
  }
I'm not sure if this would technically be undefined behavior, though, as the C standard only explicitly permits computing a pointer one past the end of the array, and other out-of-bounds computations are undefined, IIRC. In practice, I don't think any compiler would miscompile this.

There are no comments on this comment yet.