This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/79142] bit shift + compare returns wrong value


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

--- Comment #1 from layer at known dot net ---
And the code:

#include <stdio.h>

/* whatever the shift in badexample does,
 * the function should never return 1
 */

long
badexample(unsigned long iv)
{
  long ov = ((long)(1)) << ((iv & 0x3f) + 1);
  if (ov == 1)
    ov = 0;
  return ov;
}

int
main()
{
  int i;
  for(i=60;i<65;i++)
    printf("%d=>0x%lx\n",i&63,badexample(i&63));
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]