www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4079] New: [CTFE] Stack overflow from undetected circular reference

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

           Summary: [CTFE] Stack overflow from undetected circular
                    reference
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-04-10 16:47:33 PDT ---
This is wrong D2 code:

int foo() {
    assert(.r == 0);
    return 0;
}
enum int r = foo();
void main() {}


dmd 2.043 shows a good enough error message (even if there's no need to print
the second error two times):

test.d(2): Error: circular reference to 'r'
test.d(5): Error: cannot evaluate foo() at compile time
test.d(5): Error: cannot evaluate foo() at compile time



This is another wrong D2 program:

int foo() {
    return r;
}
enum int r = foo();
void main() {}


But this time dmd 2.043 shows:
Stack overflow

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4079


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|diagnostic                  |ice-on-invalid-code
                 CC|                            |clugdbug yahoo.com.au


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-04-10 21:40:38 PDT ---
This looks similar to bug 2315, but I suspect the cause may be quite different.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4079


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Don <clugdbug yahoo.com.au> 2012-04-03 01:00:32 PDT ---
Fixed a couple of releases ago. Now on both D1 and D2, it displays a message
like:

bug.d(42): Error: function bug.foo CTFE recursion limit exceeded
bug.d(43):        called from here: foo()
bug.d(42):        1000 recursive calls to function foo
bug.d(45):        called from here: foo()

and the first case doesn't have a repeated error message, it now displays:

bug.d(47): Error: cannot evaluate foo() at compile time. Circular reference?
bug.d(43):        while evaluating r.init
bug.d(47):        called from here: foo()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2012