Bug 11007 – std.format.formattedRead with %*s specifier causes AssertError
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-10T07:48:43Z
Last change time
2019-11-15T10:00:25Z
Keywords
pull
Assigned to
No Owner
Creator
Tomoya Tanjo
Comments
Comment #0 by ttanjo — 2013-09-10T07:48:43Z
The following code throws AssertError with the message "format.d(3790): Format specifier not understood: %s" in dmd v2.064-devel-fe5dfc5 on Linux 64bit.
It should throw an exception (not Error) or should be accepted.
---
import std.format;
void main()
{
string str = "foo bar buzz";
string a, b;
formattedRead(str, "%s %*s %s", &a, &b);
}
---
If we use "%*d" instead of "%*s", it runs without errors.
Comment #1 by bugzilla — 2019-11-14T16:04:16Z
(In reply to Tomoya Tanjo from comment #0)
> If we use "%*d" instead of "%*s", it runs without errors.
Actually, that's an other bug. It shouldn't work, because there is no number...
Comment #2 by dlang-bot — 2019-11-14T16:16:59Z
@berni44 created dlang/phobos pull request #7277 "Fix Issue 11007 - std.format.formattedRead with %*s specifier causes AssertError" fixing this issue:
- Fix Issue 11007 - std.format.formattedRead with %*s specifier causes AssertError
https://github.com/dlang/phobos/pull/7277
Comment #3 by bugzilla — 2019-11-14T18:28:31Z
I filed two more issues: Issue 20392 and Issue 20393 to distinguish between the different problems.
Here the problem is, that this works, but the one above not.
---
import std.format;
void main()
{
string str = "foo bar buzz";
string a, b, c;
formattedRead(str, "%s %s %s", &a, &b, &c);
}
---
IMHO %*s should be added (and several others like %*x) to fix this bug.
(In reply to Tomoya Tanjo from comment #0)
> It should throw an exception (not Error) or should be accepted.
As atilaneves and MoonlightSentinel pointed out in PR 7277, the error is correct, because this is high likely a programmers error and not a user mistake.