Mail Archives: djgpp/2000/08/01/13:10:39
> 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 -