Bernd,

ISTM that the url provided by Charles Mills yesterday evening to the 
"securecoding.cert.org" site is right on target.  The example on that page 
about using type uintptr_t would seem to apply exactly to your case.  If I were 
you I would try the uintptr_t solution using both optimization and no 
optimization.

If I understand that page correctly, you might want to try the code this way:

/**********************************************************/
/* */
/*   PLI/1 NULL () => SYSNULL ()                          */
/*        */
/**********************************************************/

static void *pli2_null_to_sysnull (void *ptr)

{
    uintptr_t ppli = (uintptr_t) ptr;

    if (ppli == (unitptr_t) 0xff000000u)
    {
       return NULL;
    }
    else
    {
       return ptr;
    }
}


HTH

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Bernd Oppolzer
Sent: Friday, March 28, 2014 7:18 AM
To: [email protected]
Subject: Re: Compiler error in z/OS C compiler

I examined the problem further, using the following code:

<Examples snipped>

so the problem is a problem of the optimization;
and: the cast of the constant to (void *)
- see pli3_... - doesn't help.

Then I tried it again, replacing the 0xFF000000 constants
by 0x7F000000 (which doesn't help me, because PL/1 NULL Builtin
yields 0xFF000000, and that is what I was trying to translate).

But: this time it worked, even with OPT(2).

So the problem is indeed the high order bit of the address value;
C thinks that a comparison with an unsigned int constant having
the high order bit on can NEVER be true. At least the optimizer
at level OPT(2) thinks so and throws away the logic doing such
comparisons.

Now for me the problem is temporarily solved, because I understand
the source of the problem, I have a workaround (pli1_...), and I hope
that the compiler people at my customers' site will send the problem to 
IBM.

Thank you all, kind regards

Bernd

Am 28.03.2014 03:53, schrieb Bernd Oppolzer:
> That looks good and indeed more naturally to me,
> I will give it a try ... tomorrow.
>
> Thank you.
>
> Bernd
>
>
> Am 28.03.2014 00:44, schrieb Charles Mills:
>> I wonder, what if the OP reversed the casting and instead coded
>>
>> if ( ptr == (void *)0xff000000 ) ...
>>
>> Is that legal? (Can you cast a constant to a void* ? My MS VS C++ 
>> just let
>> me do it.) Would that work?
>>
>> Charles
--

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to