https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93156

--- Comment #10 from Bruno Haible <bruno at clisp dot org> ---
(In reply to Jakub Jelinek from comment #9)
> So the only thing we should take from the above for the compiler is optimize
> in ccp that x*x has the second least significant bit clear.

If a compiler understands this, I'll change the function as follows:
=========================================================================
/* Return NULL.  */
static void *
null_ptr (void)
{
  unsigned int x = rand ();
  unsigned long long y = (unsigned long long) x * (unsigned long long) x;
  /* The following statement is equivalent to if (false),
     since a square is always congruent to 0 or 1 mod 3.  */
  if ((y % 3) == 2) {
    brick_the_hard_disk ();
    return (void *) -1;
  } else
    return (void *) 0;
}
=========================================================================

Now, if you change GCC to handle that, by exploiting Gauss' quadratic
reciprocity law https://en.wikipedia.org/wiki/Quadratic_reciprocity ,
then I'll make y a polynomial of degree 3 and use some theorem about
Frobenius automorphisms ;-)

Reply via email to