SIG11 crashing - can't figure it out

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 15 06:48:31 PDT 2015


On 5/15/15 7:08 AM, "Rob =?UTF-8?B?UGlla8OpIg==?= <robpieke at gmail.com>" 
wrote:
> Working my way through Ali Çehreli's rather amazing e-book, I've hit a
> snag where some code I've written is pretty crashy. I consistently get
> "Segmentation fault: 11" (dmd 2.067.1, OSX).


Using dustmite (and 2.067.0), I reduced it to this:


enum Suit {
DIAMONDS, CLUBS}

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

struct Card {
     Value value;
     Suit suit;
}

void printCard(Card card) {
     final switch(card.value) {
     case Value.ACE:
;
     case Value.TWO, Value.THREE, Value.FOUR, Value.FIVE, Value.SIX, 
Value.SEVEN, Value.EIGHT, Value.NINE, Value.TEN:
;
     case Value.JACK:
;
     case Value.QUEEN:
;
     case Value.KING:
;
     }
}

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


But before I figured out how to use dustmite (it was my first time), I 
hand reduced it to this:

struct Card {
     int value;
     int suit;
}

void foo(Card card) {
     switch(card.value) {
     case 4: case 5: case 6: case 11:
         break;
     default:
     }
}

void main() {
     auto card = Card(11, 1);
     foo(card);
}

I see you filed a bug, I'll update with the reduced case.

-Steve


More information about the Digitalmars-d-learn mailing list