This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: IRIX64 6.5, gcc 2.95.1: weird inet_ntoa() behaviour


I thougth this was in the gcc FAQ, but .. 


From
http://toolbox.sgi.com/TasteOfDT/public/freeware/Installable/gcc-2.95.2.html
[From Jim Wilson] Gcc does not correctly pass/return structures which are
smaller than 16 bytes and which are not 8 bytes. The problem is very
involved and difficult to fix. It affects a number of other targets also,
but irix6 is affected the most, because it is a 64 bit target, and 4 byte
structures are common. The exact problem is that structures are being padded
at the wrong end, e.g. a 4 byte structure is loaded into the lower 4 bytes
of the register when it should be loaded into the upper 4 bytes of the
register. 
Gcc is consistent with itself, but not consistent with the SGI C compiler
[and the SGI supplied runtime libraries], so the only failures that can
happen are when there are library functions that take/return such
structures. There are very few such library functions. I can only recall
seeing a few of them: inet_ntoa, inet_aton, inet_lnaof, inet_netof, and
semctl.


+++++++++++++++++++++++++++++++++++++++++
(Mr) David Billinghurst
Comalco Research Centre
PO Box 316, Thomastown, Vic, Australia, 3074
Phone:	+61 3 9469 0642
FAX:	+61 3 9462 2700
Email:	David.Billinghurst@riotinto.com.au




> -----Original Message-----
> From:	Denis Vakatov [SMTP:vakatov@peony.nlm.nih.gov]
> Sent:	Thursday, 25 May 2000 0:52
> To:	gcc@gcc.gnu.org
> Cc:	vakatov@peony.nlm.nih.gov; lavr@peony.nlm.nih.gov
> Subject:	IRIX64 6.5, gcc 2.95.1:  weird inet_ntoa() behaviour
> 
> Hi,
> 
> See the attached code:
> 
> inet_ntoa() produces an invalid result when the following code
> compiled with GCC.
> However, it produces a correct result when compiled with native "cc".
> 
> ?
> Denis Vakatov
> Anton Lavrentiev
> 
> 
> --------------------------------------------------------------------------
> ---
> > uname -a
> IRIX64 muncher 6.5 10181058 IP27
> > gcc --version
> 2.95.1
> 
> > cat - > inet_ntoa.c
> #include <net/if.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
> #include <stdio.h>
> 
> int main(void)
> {
>   struct sockaddr_in sin;
> 
>   sin.sin_family = AF_INET;
>   sin.sin_port = 0x1234;
>   sin.sin_addr.s_addr = 0x820E1923;
> 
>   printf("%s\n", inet_ntoa(sin.sin_addr));
>   return 0;
> }
> 
> 
> > gcc inet_ntoa.c 
> > a.out
> 255.255.255.255
> 
> 
> > cc inet_ntoa.c 
> > a.out
> 130.14.25.35

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]