Article View: gnu.gcc.bug
Article #784inet_makeaddr returns 0
From: Bjorn Victor
Date: Mon, 13 Nov 1989 13:02
Date: Mon, 13 Nov 1989 13:02
47 lines
1827 bytes
1827 bytes
Environment:
Sun 4/260 running SunOS 4.0.1
"gcc version 1.36"
"GNU CPP version 1.36"
"GNU C version 1.36 (sparc) compiled by CC."
"Gnu assembler version 1.34 (I guess.)"
(unknown version of GNU loader)
Give the following program (an extract from the original):
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main(argc,argv)
int argc;
char *argv[];
{
struct in_addr naddr;
int net;
char *string;
net = atoi(argv[1]);
naddr = inet_makeaddr(net,0);
printf("Net = %d, Netaddr = %lu\n",net,naddr.s_addr);
string = inet_ntoa(&naddr);
printf("Or rather: %s\n", string);
}
When compiled with Sun's /bin/cc, the program runs OK (net = 10 gives
naddr.s_addr = 167772160).
When compiled with gcc, the call to inet_makeaddr() always returns 0,
which is incorrect. Using the -fpcc-struct-return option doesn't make
it work.
With gcc version 1.35 on a Sun 3/60 running the same OS, the program works.
If I compile the BSD4.3 definition of inet_makeaddr with gcc, the
combination works, but I can't recompile the system with gcc...
Please aid me, since I'd really love to use gcc for all C code I write!
Yours,
-- Bjorn Victor victor@DoCS.UU.SE
Dept. of Computer Systems or victor%DoCS.UU.SE@uunet.UU.NET
Uppsala University, Sweden "I'd rather hack a Lisp Machine!"
Technical Details
Message-ID:
<8911131302.AA13658@mizar.DoCS.UU.SE>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!MIZAR.DOCS.UU.SE!victorShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!MIZAR.DOCS.UU.SE!victor From: victor@MIZAR.DOCS.UU.SE (Bjorn Victor) Newsgroups: gnu.gcc.bug Subject: inet_makeaddr returns 0 Message-ID: <8911131302.AA13658@mizar.DoCS.UU.SE> Date: 13 Nov 89 13:02:08 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 47