digitalmars.D.bugs - [Issue 3363] New: std.stream.readf segfaults with immutable format strings
- d-bugmail puremagic.com (30/30) Oct 04 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3363
- d-bugmail puremagic.com (17/17) Dec 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3363
- PlatisYialos (6/6) May 18 2012 Indeed this issue is still open.
http://d.puremagic.com/issues/show_bug.cgi?id=3363 Summary: std.stream.readf segfaults with immutable format strings Product: D Version: 2.032 Platform: Other OS/Version: Linux Status: NEW Severity: major Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: acehreli yahoo.com 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 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 04 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3363 Witold Baryluk <baryluk smp.if.uj.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch, rejects-valid CC| |baryluk smp.if.uj.edu.pl 11:38:23 PST --- 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? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 01 2010
Indeed this issue is still open. I've resorted to doing the following, in order to make obvious (to a future reader of the code) the bug: int charsRead = fin.readf(cast(char []) "%c\n", &myChar); Maybe a unittest should be included in the appropriate place within stream.d?
May 18 2012