delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/20/21:17:51

Xref: news2.mv.net comp.os.msdos.djgpp:4057
From: Tom Wheeley <tomw AT tsys DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: bugs in cwsdpmi?
Date: Sun, 19 May 96 15:43:35 GMT
Organization: City Zen FM
Lines: 40
Message-ID: <832520615snz@tsys.demon.co.uk>
References: <4nlke7$aka AT news1 DOT goodnet DOT com>
Reply-To: tomw AT tsys DOT demon DOT co DOT uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <4nlke7$aka AT news1 DOT goodnet DOT com> snarfy AT goodnet DOT com  writes:

> 
> Here is an interesting 'bug' that I have found in cwsdpmi.  When I compile
> the attached file and run it under dos, it blows up giving me a SIGSEGV, but
> it works correctly under a windows dos box and in linux dosemu.  Here
> is the program:
> 
> #include <stdio.h>
> 
> typedef struct {
> int x;
> int y;
> } foo;
> 
> foo *bar;
> void main()
> {
>      bar->x = 3;
>      bar->y = 4;
>      printf("x = %d\n", bar->x);
> }
> 
> 
> As you can see, there isn't much to this program, and I have compiled
> programs that are a lot more complex than this with the exact same
> system setup with no problems.

Ever tried allocating memory for your structs?  Where do you think bar
points to?  Are you kicking yourself yet? :-)

oh and void main(); is bad.  Use main(); or int main();

..splitbung
-- 
* TQ 1.0 * The 'Just So Quotes'.
OLTION'S COMPLETE, UNABRIDGED HISTORY OF THE UNIVERSE
Bang!      ...crumple.
        -- Jery Oltion

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019