delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/12/05:15:26

From: Till Harbaum <harbaum AT ibr DOT cs DOT tu-bs DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Error in DJGPP?
Date: 12 Feb 1998 11:03:53 +0100
Organization: TU Braunschweig, Informatik (Bueltenweg), Germany
Lines: 57
Distribution: world
Message-ID: <yksen192l86.fsf@flens.ibr.cs.tu-bs.de>
NNTP-Posting-Host: flens.ibr.cs.tu-bs.de
Mime-Version: 1.0 (generated by tm-edit 7.106)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi!

While compiling a compiler test program (config.c by
Steven Pemberton) we detected a very strange problem
with djgpp. Under all other os's we tested 
(linux-gcc, dos-quickc, tos-gcc and tos-turboc) this
program just worked fine. Except with djgpp 2.01.
The djgpp compiled binary just didn't do any output.
If you flush output before the malloc thing everything
is fine. If you don't flush output all text stored 
in the output buffers is lost. 

Am i doing something wrong? Is this a compiler error?

Ciao,
  Till

--
Dipl.-Inform. Till Harbaum
Institute of Operating Systems and Computer Networks   Tel.: +49 531 391-3101
Technical University of Braunschweig                   Fax.: +49 531 391-5936 
Bültenweg 74/75, 38106 Braunschweig, Germany   EMail: harbaum AT ibr DOT cs DOT tu-bs DOT de

A program demonstrating the problem:

/* Demonstration source for stdout/malloc error, use:	*/
/* gcc -Wall -s -DERROR=0 djgpper.c -o djgpper0.exe	*/
/* gcc -Wall -s -DERROR=1 djgpper.c -o djgpper1.exe	*/
/* djgpper0.exe > djgpper0.log				*/
/* djgpper1.exe > djgpper1.log				*/

#include <stdio.h>
#include <stdlib.h>

#ifndef ERROR
#error Please define ERROR=0 (work around) or ERROR=1 (wrong behavior)
#endif

int main(void) {
unsigned long size;

puts("This text you expect to see, but maybe you won't.");

#if ERROR==0
fflush(stdout);
#endif

for (size=1<<(8*sizeof(unsigned long)-2); size!=0; size/=2)
  while (malloc(size)!=NULL);

puts("Same to this text.");
return(0);
}

- Raw text -


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