News for hackers. Stuff that matters.
Re:C++26: A User-Friednly assert() macro by teo_zero on Sunday March 29, 2026 @03:23AM (#47561066)
> it is legal to optimize out any code paths that rely on this, even if they occur earlier in program order.

I don't think this is true. The compiler cannot remove or reorder instructions that have a visible effect.

  if (p == 0)
    printf("Ready?\n");
  *p++;
The printf() can't be omitted.
Re:C++26: A User-Friednly assert() macro by saagarjha on Sunday March 29, 2026 @04:18AM (#47561291)
No, this is explicitly legal. Most compilers will shy away from it these days since it made a lot of people upset, but it's definitely allowed.
Re:C++26: A User-Friednly assert() macro by aw1621107 on Sunday March 29, 2026 @04:13AM (#47561275)
> The compiler cannot remove or reorder instructions that have a visible effect.

You might be surprised! When it comes to UB compilers can and do reorder/eliminate instructions with side effects, resulting in "time travel" [0].

IIRC the upcoming version of the C standard bans this behavior, but the C++ standard still allows it (for now, at least).

[0]: https://devblogs.microsoft.com/oldnewthing/20140627-00/?p=63...