Segfault on simple struct manipulation

Peter Thomassen info at peter-thomassen.de
Mon Aug 14 18:21:00 PDT 2006


Hi there,

I'm coming from PHP and am very new to compiled languages, so maybe I'm
completely wrong.

I have the following bitsort.d:

import std.stdio;
struct List {
        uint value;
}
void main() {
        List* list;
        writefln("This is shown.");
        list.value = 5;
        writefln("This is not shown.");
}

And this happens:

peter at tux ~/D $ dmd bitsort.d
gcc bitsort.o -o bitsort -m32 -lphobos -lpthread -lm
peter at tux ~/D $ ./bitsort
This is shown.
Segmentation fault (core dumped)
peter at tux ~/D $ 


Is this a bug?
Peter



More information about the Digitalmars-d mailing list