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

            Bug ID: 98789
           Summary: Error with bit-operation after macro operation
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: maxim81m at mail dot ru
  Target Milestone: ---

Created attachment 50029
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50029&action=edit
contains data for Debian10: README (compilers parameters), 1.i; 1.c; 1.s; 1.o
files

Good Day.

Error on x86-64 platform for Slackware 12 (gcc 4.3.3) and Debian 10 (gcc
8.3.0).
In platforms i386 works good. 

Build command: gcc -save-temps 1.c
Running: ./a.out

( I did rename 1.c to 1.cpp and build with g++ error is same )

The compilers parameters are in attachment. 

CODE:

     1  #include <stdio.h>
     2
     3  int main()
     4  {
     5
     6  typedef unsigned long int UINT4;
     7
     8  #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
     9  #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
    10
    11  UINT4 a, b, c, d, x;
    12
    13  a =  0x0da0d5a9;
    14  printf("%010x\n", a ); // result: 0x0da0d5a9
    15  a = ROTATE_LEFT(a, 7);
    16  printf("%010x\n", a ); // result: 0xd06ad486
    17
    18  printf("\n" );
    19
    20  a =  0x0da0d5a9;
    21  printf("%010x\n", a ); // result: 0x0da0d5a9
    22  a = ROTATE_LEFT(a, 7);
    23  printf("%010x\n", a ); // result: 0xd06ad486 <<< OK
    24
    25  printf("\n" );
    26
    27  x = 0x36363132;
    28  a = 0x67452301;
    29  b = 0xefcdab89;
    30  c = 0x98badcfe;
    31  d = 0x10325476;
    32
    33  a += F ((b), (c), (d)) + (x) + (UINT4)(3614090360U);
    34  printf("%010x\n", a ); // result: 0x0da0d5a9 as in string 13
    35  a = ROTATE_LEFT(a, 7);
    36  printf("%010x\n", a ); // result: 0xd06ad586 <<< ERROR
    37
    38  return 0;
    39  }
    40

Thank You for a time.

Reply via email to