www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/21/15:07:53

Xref: news2.mv.net comp.os.msdos.djgpp:4095
From: terra AT diku DOT dk (Morten Welinder)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: bugs in cwsdpmi?
Date: 19 May 1996 12:41:52 GMT
Organization: Department of Computer Science, U of Copenhagen
Lines: 31
Sender: terra AT tyr DOT diku DOT dk
Message-ID: <4nn4ug$i63@vidar.diku.dk>
References: <4nlke7$aka AT news1 DOT goodnet DOT com>
NNTP-Posting-Host: tyr.diku.dk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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);
>}


You should thank CWSDPMI for pointing out that this code is buggy!
Variable "bar" starts out as NULL and the first thing you do is to
follow it; this is undefined behaviour in C.  Try allocating a bit
of memory for it.

Morten Welinder
terra AT diku DOT dk

- Raw text -


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