Well I think it is a bug.
the following source:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
int main( int argc, char **argv )
{
uint64_t n = 0x0034000000000000LLU;
uint32_t b = n >> 32;
printf( "%08X %08X\n", b );
}
With OPT(0) it generated:
LARL r5,F'46'
* {
* uint64_t n = 0x0034000000000000LLU;
IILL r0,H'0'
IILH r0,H'52'
ST r0,n(,r13,160)
LA r2,0
ST r2,n(,r13,164)
* uint32_t b = n >> 32;
L r6,n(,r13,160)
L r7,n(,r13,164)
SRDL r6,32
LR r0,r7
ST r0,b(,r13,168)
*
* printf( "%08X %08X\n", b );
L r15,=V(PRINTF)(,r3,102)
LR r4,r5
LA r1,#MX_TEMP1(,r13,152)
ST r4,#MX_TEMP1(,r13,152)
ST r0,#MX_TEMP1(,r13,156)
BASR r14,r15
LR r15,r2
and printed: 00340000*00340000*
With OPT(3) it generated:
* {
* uint64_t n = 0x0034000000000000LLU;
IILL r0,H'0'
IILH r0,H'52'
* uint32_t b = n >> 32;
*
* printf( "%08X %08X\n", b );
LARL r1,F'26'
L r15,=V(PRINTF)(,r3,74)
ST r1,#MX_TEMP1(,r13,152)
ST r0,#MX_TEMP1(,r13,156)
LA r1,#MX_TEMP1(,r13,152)
BASR r14,r15 * {
* uint64_t n = 0x0034000000000000LLU;
IILL r0,H'0'
IILH r0,H'52'
* uint32_t b = n >> 32;
*
* printf( "%08X %08X\n", b );
LARL r1,F'26'
L r15,=V(PRINTF)(,r3,74)
ST r1,#MX_TEMP1(,r13,152)
ST r0,#MX_TEMP1(,r13,156)
LA r1,#MX_TEMP1(,r13,152)
BASR r14,r15
* }
LA r15,0
and printed: 00340000 *10000000*
This is z/OS 1.13. I am not sure about the C compiler maintenance
level, but I can check.
regards, Tom
On 2013-07-22 12:00 AM, IBM-MAIN automatic digest system wrote:
Date: Sun, 21 Jul 2013 20:42:54 +0800 From: David Crayford
<dcrayf...@gmail.com> Subject: Re: [MVS-OE] Looking for help with an
obscure C integer problem On 21/07/2013 8:40 PM, Shmuel Metz (Seymour
J.) wrote:
>In<51eb3a4c.8010...@gmail.com>, on 07/21/2013
> at 09:33 AM, David Crayford<dcrayf...@gmail.com> said:
>
>>I don't like it because it's a hack to work around an puzzling
>>issue. I want to know why the optimizer is not generating the
>>correct code.
>Why not report it as a bug?
>
We don't know if it is a bug without seeing Charles code asis.
--
G. Tom Russell
“Stay calm. Be brave. Wait for the signs.” — Jasper FriendlyBear
“... and remember to leave good news alone.” — Gracie HeavyHand
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN