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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 1 10:53:50 PST 2011


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 at puremagic.com
        ReportedBy: code at klickverbot.at


--- Comment #0 from klickverbot <code at klickverbot.at> 2011-03-01 10:50:58 PST ---
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
#0  0x00087246 in expandTuples ()
#1  0x0012c6a9 in TupleExp::interpret ()
#2  0x0012963d in ExpStatement::interpret ()
#3  0x00129696 in CompoundStatement::interpret ()
#4  0x00129696 in CompoundStatement::interpret ()
#5  0x0012f44a in FuncDeclaration::interpret ()
#6  0x0012fb73 in CallExp::interpret ()
#7  0x000dfcc7 in CallExp::optimize ()
#8  0x000b7c28 in ExpInitializer::semantic ()
#9  0x000574b1 in VarDeclaration::semantic2 ()
#10 0x000c6912 in Module::semantic2 ()
#11 0x000c4388 in main ()
---

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: -------


More information about the Digitalmars-d-bugs mailing list