Ah, that (alas) makes sense.

Would still be good if, instead of eating the extra parameters, the runtime 
left them alone, so you'd get:

This message has one two three four five six seven eight nine %10$s %11$s 
parameters.

Then at least it would be clear what happened, rather than blaming the caller. 
Seems like if it's handling 9, a simple check that says, "Is the next character 
after the digit a $?" (and a branch around if not) would enable this with 
negligible overhead.

-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of 
Linda Chui
Sent: Tuesday, October 21, 2025 12:53 PM
To: [email protected]
Subject: Re: Anyone using XL C?

On Mon, 20 Oct 2025 16:51:30 -0400, Phil Smith III <[email protected]> wrote:

>Great! Will it warn about more %n$ than are supported? I hope? Not that we're 
>likely to make that mistake again...
>
>...phsiii (limping still from self-inflicted foot wound)
>

Unfortunately, that is something most compilers won’t be able to do since it 
depends on the execution environment. i.e. The limit is dependent on the C 
runtime environment (given by the limits.h header and the specific 
implementation of printf used at runtime). The compiler itself can generally 
NOT know what the runtime environment is, so it can’t know the actual limit, 
and hence can’t diagnose it reliably.

For example, say you are planning on using your own specially created C runtime 
(“Phil’s Super POSIX environment for z/OS!”) that allows 42 positional 
arguments. You would not want the compiler to complain saying that it only 
allows 9 positional arguments (since it is assuming Language Environment for 
that particular version/release is being used, and the application won’t be 
used on any future version/release of LE).



Regards,

z/OS XL C/C++ Compiler Team

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

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

Reply via email to