On Sat, 23 Aug 2025 15:09:16 -0500, Charles Mills <[email protected]> wrote:

>        memcpy(a, b, 7);
>sorry if this disappoints you -- the IBM XLC V3R1 compiler simply generated
>D206  9868  9870

I suspected this because IBM tends to do things right. Far more impressive 
would be if IBM did FOPEN right. IF you specify RECFM=FB LRECL=80, does it pass 
a string, a DCB or separate args.

>At optimization levels 0 and 1, it did indeed load 7 into a register and make 
>a call to a generic memcpy() routine.

Expected but if I was doing C on z/OS, it would be disappointing. Optimization 
2 gives you MVC which could potentially yield very different results than 
calling the generic memcpy(). If this was the only one, then fine but I suspect 
this common.

>At optimization level 2, the compiler was smart enough to figure out that a 
>was never referenced

This has been true for decades. Lazy programmers will delete the reference 
knowing the rest will be suppressed.

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

Reply via email to