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

            Bug ID: 78135
           Summary: In an unsigned long (64 bit) 1<<31 gives rubbish
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmdh01 at btinternet dot com
  Target Milestone: ---

Created attachment 39911
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39911&action=edit
gcc_version+specimen.c+specimen.i example program demonstrating bug

It would appear that left shifting a single bit into bit 31 causes the result
to be "sign extended". This could be caused by either a hardware quirk or over
enthusiastic optimisation forgetting that the operand is unsigned or a
combination of both. Example program attached. This bug is horrible: the code
emitted by gcc is ok for 98% percent of the time; it took a whole week to track
down this particular gem.

gcc -g -o specimen2 -Wall -Wextra specimen.c  only complains about an unused
variable.

The problem manifests itself using an Intel J1900 and an i5-6400 both with 8GB
ram.

Operating System: Ubuntu 16.04.1 (with Trinity)
Kernel: linux 4.4.0-45-generic (x86_64)

Attachments:
1) gcc_version.txt
2) specimen.c -- source of example program
3) specimen.i -- as requested

Reply via email to