www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5676] New: Evaluating nested std.typecons.tuple calls at compile time crashes DMD

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

           Summary: Evaluating nested std.typecons.tuple calls at compile
                    time crashes DMD
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
Trying to compile the following program crashes DMD (from current Git, a47637):
---
import std.typecons;
enum foo = tuple("foo", tuple("bar"));
---

The backtrace from GDB:
---
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000011
0x00087246 in expandTuples ()
(gdb) bt












---

The above backtrace seems to indicate a bug in CTFE. Indeed, if the value isn't
computed at compile time, everything works fine:
---
import std.stdio;
import std.typecons;

void main() {
    auto foo = tuple("foo", tuple("bar"));
    writeln(foo); // prints Tuple!(string,Tuple!(string))(foo,
Tuple!(string)(bar)).
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5676


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
            Summary|Evaluating nested           |[CTFE] segfault using tuple
                   |std.typecons.tuple calls at |containing struct that has
                   |compile time crashes DMD    |opAssign
         OS/Version|Mac OS X                    |All



Reduced test case. It happens with compile time assignment to a tuple which
contains an object with an opAssign. Not a regression, failed in 2.040 as well.

struct S5676
{
    int x;
    void opAssign(S5676 rhs) { x = rhs.x;}
}

struct Tup5676(E...)
{
    E g;
    void foo(E values) { g = values; }
}

bool ice5676()
{
    Tup5676!(S5676) q;
    q.foo( S5676(3) );
    assert( q.g[0].x == 3); // crashes here
    return true;
}

static assert(ice5676());

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 24 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5676


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



17:30:59 PDT ---
https://github.com/D-Programming-Language/dmd/commit/766ff55baceec3a8d00d23ece02ff4aadc6b9209

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 26 2011