🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #41652

Re: GCC 2.7.2 on Solaris 2.4 compiles wrong with -ansi !!

#41652
From: Ronald F. Guilmette
Date: Sat, 02 Mar 1996 00:00
51 lines
2360 bytes
In article <4h16jm$631@signal.dra.hmg.gb>,
David C. M. Bilsby <bilsby@panther.dra.hmg.gb> wrote:
>Hi,
>	A collegue spotted the following problem and blaimed me as system
>admin, however I think its gcc 2.7.2 under Solaris 2.4 thats at fault.
>
>	If you compile the following code to calculate a simple pythagorus
>triangle problem with :
>
>	% gcc -o testprog testprog.c -lm   
>
>then
>
>	% gcc -ansi -o testprog testprog.c -lm 
>
>you get 
>	
>	3.000000 4.000000 5.000000
>and
>	3.000000 4.000000 1074266112.000000
>
>respectively, ie. wrong with -ansi flag.
>
>If you add -Wall to the -ansi option things start to become clearer :
>
>	% gcc -ansi testprog.c -o testprog -lm -Wall
>	testprog.c:6: warning: return-type defaults to `int'
>	testprog.c: In function `main':
>	testprog.c:10: warning: implicit declaration of function `hypot'
>	testprog.c:13: warning: control reaches end of non-void function
>
>It shows that the hypot function is assumed to have int return value. However
>it is defined correctly in the /usr/include/math.h header It is defined
>within a strange #if preprocessor which means it is not included when gcc
>compiles with either -ansi or not. Without the -ansi it does not seem
>to matter too much. The include is :
>
>[stuff]
>#if __STDC__ - 0 == 0 && !defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)

You should _not_ be getting <math.h> from /usr/include... and you wouldn't
be if you had properly run the fixinc.svr4 script during gcc building and
installation.

That script puts ``fixed'' copies of the include files into another place
where GCC _should_ look for them first, before it looks in /usr/include.
-- 

-- Ron Guilmette, Roseville, CA -------- Infinite Monkeys & Co. ------------
---- E-mail: rfg@monkeys.com ----------- Purveyors of Compiler Test Suites -
------ Copyright (c) 1996 by Ronald F. Guilmette; All rights reserved. -----
Technical Details
Message-ID: <4h98gi$qnk@segfault.monkeys.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4h16jm$631@signal.dra.hmg.gb>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b65cdfcedc85c7d
X-Google-Attributes: gid11318c,public
From: rfg@monkeys.com (Ronald F. Guilmette)
Subject: Re: GCC 2.7.2 on Solaris 2.4 compiles wrong with -ansi !!
Date: 1996/03/02
Message-ID: <4h98gi$qnk@segfault.monkeys.com>
X-Deja-AN: 141782577
references: <4h16jm$631@signal.dra.hmg.gb>
organization: Infinite Monkeys & Co.
newsgroups: gnu.gcc.help