Bug 3363 – std.stream.readf segfaults with immutable format strings
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
Other
OS
Linux
Creation time
2009-10-04T14:23:00Z
Last change time
2014-07-11T23:28:01Z
Keywords
patch, pull, rejects-valid
Assigned to
nobody
Creator
acehreli
Comments
Comment #0 by acehreli — 2009-10-04T14:23:03Z
This program segfaults when run and receives an int from din:
import std.cstream;
void main()
{
int i;
din.readf("%d", &i);
}
The reason is because vreadf does not think that "%d" is a format string, probably because the following 'is' expression doesn't match immutable (char)[]:
std/stream.d:694: if (arguments[j] is typeid(char[])) {
The program above works as expected when readf receives "%d".dup
Ali
Comment #1 by witold.baryluk+d — 2010-12-01T11:38:23Z
Why this bug isn't fixed yet? It is trivial to fix and important, as many users (especially beginners) will encounter this problem.
changing std/stream.d:694:
if (arguments[j] is typeid(char[])) {
into
if (arguments[j] is typeid(string) || arguments[j] is typeid(char[])) {
would fix it right?