[Issue 14587] New: DMD 2.067.1 generating crashing binary on OSX

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 15 06:08:02 PDT 2015


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

          Issue ID: 14587
           Summary: DMD 2.067.1 generating crashing binary on OSX
           Product: D
           Version: unspecified
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: robpieke at mail.com

(reporting as an issue - suggested by John Colvin)

I'm consistently getting "Segmentation fault: 11" (dmd 2.067.1, OSX) on the
code below.

I can't figure out where things are going wrong, because any attempt I make to
debug via extra print statements causes the program to run successfully. Same
if I try to compile with "-gc" ... it suddenly starts working, so I can't debug
with gdb. And the code similarly seems to work fine with ldc2.

Many thanks in advance!

* * *

import std.stdio;

enum Suit {
    HEARTS, DIAMONDS, CLUBS, SPADES
}

enum Value {
    ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, 
JACK, QUEEN, KING
}

struct Card {
    Value value;
    Suit suit;
}

void printCard(in Card card) {
    final switch(card.value) {
        case Value.ACE:
            write("A");
            break;
        case Value.TWO, Value.THREE, Value.FOUR, Value.FIVE, Value.SIX, 
Value.SEVEN, Value.EIGHT, Value.NINE, Value.TEN:
            writef("%d", card.value);
            break;
        case Value.JACK:
            write("J");
            break;
        case Value.QUEEN:
            write("Q");
            break;
        case Value.KING:
            write("K");
            break;
    }
    final switch(card.suit) {
        case Suit.HEARTS:
            write("♡");
            break;
        case Suit.DIAMONDS:
            write("♢");
            break;
        case Suit.CLUBS:
            write("♣");
            break;
        case Suit.SPADES:
            write("♠");
            break;
    }
    write("\n");
}

int main() {
    auto card = Card(Value.JACK, Suit.CLUBS);
    printCard(card);
    return 0;
}

--


More information about the Digitalmars-d-bugs mailing list