www.digitalmars.com         C & C++   DMDScript  

D - Getting seg. fault when compiling simple project

reply Dave Andrews <Dave_member pathlink.com> writes:
I just began learning/using D, and since I'm an obsessive compulsive game
programmer I decided to write up a very, very simple little guess-the-number
game just to use some basic D ideas.

I used DIDE on Windows XP, using dmd version 0.78, and Kate on Red Hat 9 to
write the same program, rh9 also using dmd v0.78.

The program consists of 2 files, main.d and NumberGame.d.  main.d is the
program, and NumberGame.d just declares class NumberGame and all its functions.

On Windows XP, I get an error message popup (from windows) saying dmd.exe has
encountered a problem and needs to be closed..  The only information I get is
that the error is at offset e8004996.

On Linux, it just says "Segmentation fault" when I run "dmd main.d
NumberGame.d".

The program compiles and runs correctly when I cut the NumberGame class out of
NumberGame.d and paste it at the top of main.d.  This I do not understand.

I've used comments to narrow down where the segmentation fault at compilation
occurs, and it occurs at the first line of my int main:

NumberGame myGame = new NumberGame;

When that line is commented out, the program compiles fine whether in 1 file or
in 2 files.

I may not be using classes correctly..  I don't believe I'm supposed to HAVE to
put all my code in one file.

This also occurs in a few D programs I've found around the internet, such as the
program submarine2 I found somewhere that uses SDL.

Any ideas what the problem/bug is?  Is it my code, and if it is, why does MY
code cause a seg. fault in dmd?
Jan 17 2004
parent "Walter" <walter digitalmars.com> writes:
"Dave Andrews" <Dave_member pathlink.com> wrote in message
news:bucr6c$15rg$1 digitaldaemon.com...
 Any ideas what the problem/bug is?  Is it my code, and if it is, why does
MY
 code cause a seg. fault in dmd?
Any time dmd seg faults, it's a bug in dmd. Please whittle it down to the smallest possible source that reproduces it, and send it to me for fixing.
Jan 17 2004