Blame gnulib/tests/null-ptr.h

Packit 06dd63
/* Return a NULL pointer, without letting the compiler know it.
Packit 06dd63
   Copyright (C) 2017-2019 Free Software Foundation, Inc.
Packit 06dd63
Packit 06dd63
   This program is free software: you can redistribute it and/or modify
Packit 06dd63
   it under the terms of the GNU General Public License as published by
Packit 06dd63
   the Free Software Foundation; either version 3 of the License, or
Packit 06dd63
   (at your option) any later version.
Packit 06dd63
Packit 06dd63
   This program is distributed in the hope that it will be useful,
Packit 06dd63
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 06dd63
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 06dd63
   GNU General Public License for more details.
Packit 06dd63
Packit 06dd63
   You should have received a copy of the GNU General Public License
Packit 06dd63
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit 06dd63
Packit 06dd63
#include <stdlib.h>
Packit 06dd63
Packit 06dd63
/* Return NULL.
Packit 06dd63
   Usual compilers are not able to infer something about the return value.  */
Packit 06dd63
static void *
Packit 06dd63
null_ptr (void)
Packit 06dd63
{
Packit 06dd63
  unsigned int x = rand ();
Packit 06dd63
  unsigned int y = x * x;
Packit 06dd63
  if (y & 2)
Packit 06dd63
    return (void *) -1;
Packit 06dd63
  else
Packit 06dd63
    return (void *) 0;
Packit 06dd63
}
Packit 06dd63
Packit 06dd63
/* If you want to know why this always returns NULL, read
Packit 06dd63
   https://en.wikipedia.org/wiki/Quadratic_residue#Prime_power_modulus .  */