[Issue 14315] New: [snn] scanf can't read lines longer than 32767 characters

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 21 13:04:11 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14315

          Issue ID: 14315
           Summary: [snn] scanf can't read lines longer than 32767
                    characters
           Product: D
           Version: D1 & D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: ag0aep6g at gmail.com

Found by Dennis Ritchie, and reduced by Ivan Kazmenko, in d.learn:
http://forum.dlang.org/thread/cilhjlyoeqgxffbosqju@forum.dlang.org

Tested through wine with DMD32 D Compiler v2.066.1.
No problem on linux. Couldn't test -m64 with wine.
Works fine with lengths up to 32767.

a.d (generates a long line):
----
import std.range, std.stdio;
void main () {'a'.repeat (100_000).writeln;}
----

b.d (tries to read it):
----
import core.stdc.stdio: printf, scanf;
import core.stdc.string: strlen;
void main () {
    char [100_000 + 1] a;
    scanf ("%s", a.ptr);
    printf("%d\n", a.ptr.strlen); /* prints "32767", should print "100000" */
}
----

Compile and run:
----
dmd a.d && dmd b.d && (./a | ./b)
----

--


More information about the Digitalmars-d-bugs mailing list