Catching std.conv.ConvException in readf causes a buffer overrun

Shigeki Karita shigekikarita at gmail.com
Wed Jun 27 02:39:49 UTC 2018


import std.stdio;
import std.conv;

void main() {
     int i;
     try {
         readf("%d\n", &i); // "a"
     } catch (ConvException e) {
         auto s = readln();
         writeln(s); // "aa", "aaa" or SEGV ???
     }
}

https://wandbox.org/permlink/NMYNjpOgQtfUprBQ

I just want to retry reading if input was invalid. How can I do 
it?


More information about the Digitalmars-d-learn mailing list