I was able to reproduce the problem with a little test program:


#include <stdio.h>
#include <stdlib.h>

static void longtest (long long lwert)
{
   int test;
   test = lwert & 0x00000000ffffffffLL;
   if (test != 0)
   {
      printf ("lwert right = %x\n", test);
   }
   else
   {
      test = lwert >> 32;
      printf ("lwert left = %x\n", test);
   }
}

int main (void)
{
   long long lwert;
   int l1;
   int l2;
   int *p;
   char zeile [85];
   fgets (zeile, 80, stdin);
   l1 = atoi (zeile);
   fgets (zeile, 80, stdin);
   l2 = atoi (zeile);
   lwert = l1;
   lwert <<= 32;
   lwert += l2;
   p = (int *) (&lwert);
   printf ("long long first part = %x\n", *p);
   printf ("long long second part = %x\n", *(p + 1));
   longtest (lwert);
}


this was compiled using z/OS XL C version 1.11.

The error only showed up when using the compile option HGPR,
that is, when the compiler used the G-instructions, like SRAG etc.

results with HGPR:

long long first part = 8000
long long second part = 0
lwert left = 0

results without HGPR:

long long first part = 8000
long long second part = 0
lwert left = 8000

this can be confirmed by looking at the ASSEMBLER code generated in both cases:

with HGPR:

*     longtest (lwert);
          LG       r0,lwert(,r13,304)
          ST       r0,lwert%2=>1(,r13,316)
            TEST LONG LONG:
          SRAG     r0,r0,32
          ST       r0,lwert%2=>1(,r13,312)
+         LG       r0,lwert%2=>1(,r13,312)
+         LTR      r0,r0
+         BE       @1L6
+         LA       r1,+CONSTANT_AREA(,r2,55)
+         ST       r0,#MX_TEMP1(,r13,228)
+         LGF      r15,=V(PRINTF)(,r3,362)
+         ST       r1,#MX_TEMP1(,r13,224)
+         LA       r1,#MX_TEMP1(,r13,224)
+         BASR     r14,r15
+         B        @1L7
+@1L6     DS       0H
+         LA       r0,+CONSTANT_AREA(,r2,73)
+         ST       r0,#MX_TEMP1(,r13,224)
+         LGHI     r0,H'0'
+         LGF      r15,=V(PRINTF)(,r3,362)
+         LA       r1,#MX_TEMP1(,r13,224)
+         ST       r0,#MX_TEMP1(,r13,228)
+         BASR     r14,r15
+@1L7     DS       0H

without HGPR:

*     longtest (lwert);
          L        r4,<a1:d240:l4>(,r13,240)
            TEST LONG LONG:
          ICM      r0,b'1111',<a1:d244:l4>(r13,244
+         BE       @1L6
+         LA       r1,+CONSTANT_AREA(,r2,55)
+         ST       r0,#MX_TEMP1(,r13,228)
+         L        r15,=V(PRINTF)(,r3,302)
+         ST       r1,#MX_TEMP1(,r13,224)
+         LA       r1,#MX_TEMP1(,r13,224)
+         BASR     r14,r15
+         B        @1L7
+@1L6     DS       0H
+         LA       r0,+CONSTANT_AREA(,r2,73)
+         LA       r5,0
+         ST       r0,#MX_TEMP1(,r13,224)
+         SRDA     r4,32
+         L        r15,=V(PRINTF)(,r3,302)
+         ST       r5,#MX_TEMP1(,r13,228)
+         LA       r1,#MX_TEMP1(,r13,224)
+         BASR     r14,r15
+@1L7     DS       0H
*  }
          LA       r15,0

look at the SRDA instrunction, which is missing in the other case.

This is a compiler error and should be repaired by IBM support.

Kind regards

Bernd




Am 27.07.2013 17:03, schrieb Bernd Oppolzer:
don't know for C, but for problems or questions concerning
the PL/1 compiler, IBM support was always very responsive
and helpful. That's my experience, at least.

You could help them by isolating the problem with a small
test program (containing for example only this function and
a little main with a test call). Provide the compile list
with the LIST option, together with the problem description.

Kind regards

Bernd

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to