You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std.format with position with omitted second number does not work #10699
Hmm indexEnd is typed as ubyte, when you do this it sets the length to 255, and then write sees that.
The format spec module does not know what the count of arguments, do so it has to use a sentinel value for this. It also won't work with arguments > 255, this needs to be thought about.
This shouldn't be a problem in practice. All programming language environments have limits in some kind. For example, ISO C 23 § 5.2.5.2 specifies a maximum of "127 arguments in one function call" for valid programs. Humans wouldn't write code with a function call with that many arguments, and it's hard to think of generated code to cross this limit.
This shouldn't be a problem in practice. All programming language environments have limits in some kind. For example, ISO C 23 § 5.2.5.2 specifies a maximum of "127 arguments in one function call" for valid programs. Humans wouldn't write code with a function call with that many arguments, and it's hard to think of generated code to cross this limit.
You didn't read the footnote:
Implementations are encouraged to avoid imposing fixed translation limits whenever possible
The fix does not work for me. I applied the patch to the GCC sources (on top of the fix of #10713), rebuilt GCC, and now the reproducer produces another exception:
After the range specifier, did you add another?
I.e. %1:$d %d
No, I'm running the exact same test program as in the description of this issue.
And yes, I'm aware of this case: For a format string like "%1:$d %d", GNU gettext's format string checker will produce the error message "The directive number 2 references an argument after the last argument."
Activity
rikkimax commentedon Mar 25, 2025
Hmm
indexEndis typed asubyte, when you do this it sets the length to 255, and then write sees that.The format spec module does not know what the count of arguments, do so it has to use a sentinel value for this. It also won't work with arguments > 255, this needs to be thought about.
bhaible commentedon Mar 26, 2025
This shouldn't be a problem in practice. All programming language environments have limits in some kind. For example, ISO C 23 § 5.2.5.2 specifies a maximum of "127 arguments in one function call" for valid programs. Humans wouldn't write code with a function call with that many arguments, and it's hard to think of generated code to cross this limit.
rikkimax commentedon Mar 26, 2025
You didn't read the footnote:
Those were minimums specified, not maximums.
I have verified that we support 512 arguments.
Fix dlang#10699 - std.format with position with omitted second number…
Fix dlang#10699 - std.format with position with omitted second number…
Fix #10699 - std.format with position with omitted second number does…
0xEAB commentedon Mar 28, 2025
@rikkimax This can be closed now, can’t it?
bhaible commentedon Mar 28, 2025
Please give me 1 day of time, to verify that the fix works on my side. Thanks.
rikkimax commentedon Mar 28, 2025
If it doesn't, reopen.
bhaible commentedon Mar 29, 2025
The fix does not work for me. I applied the patch to the GCC sources (on top of the fix of #10713), rebuilt GCC, and now the reproducer produces another exception:
Actual output now:
Can you please reopen the issue? (I don't have permissions to do that.)
rikkimax commentedon Mar 29, 2025
Looks like it is coming afoul of: https://github.com/dlang/phobos/blob/stable/std/format/write.d#L609
I was kinda expecting something like this to crop up.
After the range specifier, did you add another?
I.e.
%1:$d %dThe above isn't a bug.
bhaible commentedon Mar 29, 2025
No, I'm running the exact same test program as in the description of this issue.
And yes, I'm aware of this case: For a format string like
"%1:$d %d", GNU gettext's format string checker will produce the error message "The directive number 2 references an argument after the last argument."rikkimax commentedon Mar 29, 2025
I copied your two cases from the original message and it passed on my end.
bhaible commentedon Mar 29, 2025
I'll try to debug it on my side, then, in the next 2 days.
Fix dlang#10699 - std.format with position with omitted second number…
bhaible commentedon Mar 30, 2025
@rikkimax , @thewilsonator : Please, can you review my pull request #10723 ?
Improve result of dlang#10699's fix so that it returns consumed argum…
Improve result of dlang#10699's fix so that it returns consumed argum…
Improve result of #10699's fix so that it returns consumed arguments …
Fix dlang#10699 - std.format with position with omitted second number…