cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/01/13:10:39

Message-Id: <200008011532.LAA14698@delorie.com>
Date: Tue, 01 Aug 2000 18:31:06 +0200
To: djgpp AT delorie DOT com
X-Mailer: Emacs 20.6 (via feedmail 8.2.emacs20_6 I) and Blat ver 1.8.5b
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
CC: ilari DOT liusvaara AT purkki DOT mbnet DOT fi
In-reply-to: <00CF54B.00640E1F47.uuout@purkki.mbnet.fi>
(ilari DOT liusvaara AT purkki DOT mbnet DOT fi)
Subject: Re: Program miscompiled by GCC
References: <00CF54B DOT 00640E1F47 DOT uuout AT purkki DOT mbnet DOT fi>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: ilari DOT liusvaara AT purkki DOT mbnet DOT fi (Ilari Liusvaara)
> Date: Sun, 22 Jul 00 22:35:00 +0200
> 
>  When I compile this program with -ansi, GCC 2.7.2.1 generates program that
>  bombs and GCC 2.9.5.2 generates program that display resluts that do not
>  make sense. The comments and messages are in finnish and I don't bother to
>  translate them. I have marked the line that generates instructions that
>  bomb the program when compiled with GCC 2.7.2.1 (at least SYMIFY tells
>  that it is that line.) When I compile without -ansi, program works just
>  fine.

The bug is in your program: it doesn't declare a prototype for the
_atold function.  When the compiler sees a function that doesn't have
a prototype, it assumes that it returns an int, whereas _atold returns
a long double.  So the code bombs.

When you compile without -ansi, the prototype for _atold that is in
stdlib.h becomes visible, and everything works.  Using -ansi masks the
prototype to avoid polluting the program's namespace.  If you use the
"-Wall" switch, you will see a warning about missing prototype.

The morale is that you cannot safely compile non-ANSI programs with
"-ansi", unless you declare prototypes for all non-ANSI functions.

- Raw text -


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