Hello,

I have a strange bug with an input range interface. Initially, I had a (rather 
big) struct called Text with loads of working unittests. When adding a range 
interface, noting worked anymore, any test ran into an infinite loop (the 
terminal writes pages of '[') ending with segfault.
After shrinking the bug's scope,I finally found it happens on simple 
writeln(text). Which is rather weird, because my toString does not iterate on 
texts properly speaking (instead on a private array field). Thus, i had the 
idea to force using toString by explicitely calling it and the bug vanished ;-) 
So, here is the situation:

unittest {
    auto text = Text("bäcon");
    writeln(text);              // --> infinite loop & segfault
    writeln(text.toString());   // OK
}

Indeed, if I remove the range interface, the bug vanishes as well.
You can find a stripped version of the module, with only the minmum to expose 
the bug, at 
https://bitbucket.org/denispir/denispir-d/changeset/39200b499fb9#chg-textbug.d. 
Note that the range interface itself works fine.

So, it seems that, in my case for any reason, introducing an input range lets D 
shortcut toString (and try to use what instead?). Look like a bug?


denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com

Reply via email to