www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3821] New: writeln doesn't detect recursive data structures yet

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3821

           Summary: writeln doesn't detect recursive data structures yet
           Product: D
           Version: 2.040
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean invisibleduck.org
        ReportedBy: bearophile_hugs eml.cc



import std.stdio, std.boxer;
void main() {
    auto a = new Box[1];
    a[0] = box(a);
    writeln(a); // Error: Stack Overflow
}

Produces a stack overflow, the writeln isn't able to detect loops yet.

In Python the print is able to detect loops:

 l = [1, 2]
 l[1] = l
 print l
[1, [...]] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3821


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



19:54:33 PDT ---
Got a newer example maybe? std.boxer is long gone.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3821




15:46:13 PST ---
Simple example:

import std.stdio;
import std.string;

class A
{
    B b;
    override string toString() { return format("A(%s)", b.toString()); }
}

class B
{
    A a;
    override string toString() { return format("B(%s)", a.toString()); }
}

void main() {
    auto a = new A;
    auto b = new B;
    a.b = b;
    b.a = a;
    writeln(a);
}

But why is this set for Druntime and to Sean Kelly? This is a Phobos issue imo.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3821






 But why is this set for Druntime and to Sean Kelly? This is a Phobos issue imo.
Maybe I was ignorant. Fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 20 2012