🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6408

Bug in 2.7.1 i486-*-linuxaout floating point

#6408
From: Patrick Caldon
Date: Mon, 27 Nov 1995 00:00
1570 lines
15076 bytes
I believe I have found a bug in gcc 2.7.1 i486-*-linuxaout.  The system
is an AMD i486/66 based linux box running linux 1.3.15, with libc version 
4.5.26. The system had nothing else unusual.  I found the bug in both 
2.7.0 and 2.7.1.

The fragment of code producing the bug is:

main()
{
        double tmp;

        tmp = (double) ntohl(1618607871 );
        printf("%f %f %d %d\n",tmp,(double) ntohl(1618607871 ),ntohl(1618607871
),1618607871 );
}

which produces the result:

4294867296.000000 4294867296.000000 -100000 1618607871

This was compiled with the command:

$ gcc t2.i

Following is the file t2.i; I hope this is of some help.

pat.

------

# 1 "t2.c"

# 1 "/usr/include/netinet/in.h" 1 3
 



















# 1 "/usr/include/features.h" 1 3
 





















 




































 









 







 



 





 








 



































 
# 1 "/usr/include/sys/cdefs.h" 1 3
 






















# 1 "/usr/include/features.h" 1 3
 

















# 136 "/usr/include/features.h" 3

# 24 "/usr/include/sys/cdefs.h" 2 3








 


# 45 "/usr/include/sys/cdefs.h" 3

   


















# 91 "/usr/include/sys/cdefs.h" 3








 







 

typedef long double __long_double_t;

# 119 "/usr/include/sys/cdefs.h" 3


 




 







 









# 134 "/usr/include/features.h" 2 3



# 21 "/usr/include/netinet/in.h" 2 3


# 1 "/usr/include/sys/socket.h" 1 3




# 1 "/usr/include/linux/socket.h" 1 3



# 1 "/usr/include/asm/socket.h" 1 3



 







 















 


# 4 "/usr/include/linux/socket.h" 2 3

# 1 "/usr/include/linux/sockios.h" 1 3
 



















 



 


























 


 

 



 




 




 




 

 





 


 


 


# 5 "/usr/include/linux/socket.h" 2 3



struct sockaddr {
  unsigned short	sa_family;	 
  char			sa_data[14];	 
};

struct linger {
  int 			l_onoff;	 
  int			l_linger;	 
};

 






					 
					 
					 
					 

 












 













 




 








 

















 



 
 


 



 





# 5 "/usr/include/sys/socket.h" 2 3


 

 



int socket  (int __family, int __type, int __protocol)  ;

 




int socketpair  (int __family, int __type, int __protocol,
		int __sockvec[2])  ;

 

int bind  (int __sockfd, struct sockaddr *__my_addr,
		int __addrlen)  ;

 



int connect  (int __sockfd, struct sockaddr *__serv_addr,
		int __addrlen)  ;

 


int listen  (int __sockfd, int __n)  ;

 




int accept  (int __sockfd, struct sockaddr *__peer,
		int *__paddrlen)  ;

 



int getsockopt  (int __s, int __level, int __optname,
		void *__optval, int *__optlen)  ;

 


int setsockopt  (int __s, int __level, int __optname,
		__const void *__optval, int optlen)  ;

 
int getsockname  (int __sockfd, struct sockaddr *__addr,
		int *__paddrlen)  ;

 

int getpeername  (int __sockfd, struct sockaddr *__peer,
		int *__paddrlen)  ;

 
int send  (int __sockfd, __const void *__buff, int __len,
		 unsigned int __flags)  ;

 

int recv  (int __sockfd, void *__buff, int __len,
		 unsigned int __flags)  ;

 

int sendto  (int __sockfd, __const void *__buff, int __len,
		 unsigned int __flags, __const struct sockaddr *__to,
		 int __tolen)  ;

 



int recvfrom  (int __sockfd, void *__buff, int __len,
		 unsigned int __flags, struct sockaddr *__from,
		 int *__fromlen)  ;

 





int shutdown  (int __sockfd, int __how)  ;


 
int rcmd  (char **__ahost, unsigned short __inport,
		__const char *__locuser, __const char *__remuser,
		__const char *__cmd, int *__fd2p)  ;
int rresvport  (int *__port)  ;
int ruserok  (__const char *__rhost, int __superuser,
		__const char *__ruser, __const char *__luser)  ;
int rexec  (char **__ahost, int __inport, __const char *__user,
		 __const char *__passwd, __const char *__cmd,
		 int *__fd2p)  ;

 


# 23 "/usr/include/netinet/in.h" 2 3


 

 
enum
  {
    IPPORT_ECHO = 7,		 
    IPPORT_DISCARD = 9,		 
    IPPORT_SYSTAT = 11,		 
    IPPORT_DAYTIME = 13,	 
    IPPORT_NETSTAT = 15,	 
    IPPORT_FTP = 21,		 
    IPPORT_TELNET = 23,		 
    IPPORT_SMTP = 25,		 
    IPPORT_TIMESERVER = 37,	 
    IPPORT_NAMESERVER = 42,	 
    IPPROT_WHOIS = 43,		 
    IPPORT_MTP = 57,

    IPPORT_TFTP = 69,		 
    IPPORT_RJE = 77,
    IPPORT_FINGER = 79,		 
    IPPORT_TTYLINK = 87,
    IPPORT_SUPDUP = 95,		 


    IPPORT_EXECSERVER = 512,	 
    IPPORT_LOGINSERVER = 513,	 
    IPPORT_CMDSERVER = 514,
    IPPORT_EFSSERVER = 520,

     
    IPPORT_BIFFUDP = 512,
    IPPORT_WHOSERVER = 513,
    IPPORT_ROUTESERVER = 520,

     
    IPPORT_RESERVED = 1024,

     
    IPPORT_USERRESERVED = 5000
  };


 





 



# 1 "/usr/include/linux/in.h" 1 3
 



















# 1 "/usr/include/linux/types.h" 1 3



 










 






typedef struct fd_set {
	unsigned long fds_bits [(256/(8*sizeof(unsigned long))) ];
} fd_set;







# 1 "/usr/include/asm/types.h" 1 3





typedef unsigned int size_t;




typedef int ssize_t;




typedef int ptrdiff_t;




typedef long time_t;




typedef long clock_t;


typedef int pid_t;
typedef unsigned short uid_t;
typedef unsigned short gid_t;
typedef unsigned short dev_t;
typedef unsigned long ino_t;
typedef unsigned short mode_t;
typedef unsigned short umode_t;
typedef unsigned short nlink_t;
typedef int daddr_t;
typedef long off_t;

 




typedef __signed__ char __s8;
typedef unsigned char __u8;

typedef __signed__ short __s16;
typedef unsigned short __u16;

typedef __signed__ int __s32;
typedef unsigned int __u32;


typedef __signed__ long long __s64;
typedef unsigned long long __u64;


 


# 76 "/usr/include/asm/types.h" 3




























# 32 "/usr/include/linux/types.h" 2 3








typedef long long loff_t;


 
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;

 
typedef unsigned char unchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;

typedef char *caddr_t;

typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;

struct ustat {
	daddr_t f_tfree;
	ino_t f_tinode;
	char f_fname[6];
	char f_fpack[6];
};


# 21 "/usr/include/linux/in.h" 2 3


 
enum {
  IPPROTO_IP = 0,		 
  IPPROTO_ICMP = 1,		 
  IPPROTO_IGMP = 2,		 
  IPPROTO_IPIP = 4,		 
  IPPROTO_TCP = 6,		 
  IPPROTO_EGP = 8,		 
  IPPROTO_PUP = 12,		 
  IPPROTO_UDP = 17,		 
  IPPROTO_IDP = 22,		 

  IPPROTO_RAW = 255,		 
  IPPROTO_MAX
};


 
struct in_addr {
	__u32	s_addr;
};

 

struct ip_mreq 
{
	struct in_addr imr_multiaddr;	 
	struct in_addr imr_interface;	 
};


 

struct sockaddr_in {
  short int		sin_family;	 
  unsigned short int	sin_port;	 
  struct in_addr	sin_addr;	 

   
  unsigned char		__pad[16  - sizeof(short int) -
			sizeof(unsigned short int) - sizeof(struct in_addr)];
};



 




























 


 


 


 


 


 




 

# 1 "/usr/include/asm/byteorder.h" 1 3
















extern unsigned long int	ntohl(unsigned long int);
extern unsigned short int	ntohs(unsigned short int);
extern unsigned long int	htonl(unsigned long int);
extern unsigned short int	htons(unsigned short int);

extern unsigned long int	__ntohl(unsigned long int);
extern unsigned short int	__ntohs(unsigned short int);
extern unsigned long int	__constant_ntohl(unsigned long int);
extern unsigned short int	__constant_ntohs(unsigned short int);

extern __inline__ unsigned long int
__ntohl(unsigned long int x)
{
	__asm__("xchgb %b0,%h0\n\t"	 
		"rorl $16,%0\n\t"	 
		"xchgb %b0,%h0"		 
		:"=q" (x)
		: "0" (x));
	return x;
}







extern __inline__ unsigned short int
__ntohs(unsigned short int x)
{
	__asm__("xchgb %b0,%h0"		 
		: "=q" (x)
		:  "0" (x));
	return x;
}










# 79 "/usr/include/asm/byteorder.h" 3



# 119 "/usr/include/linux/in.h" 2 3


 








# 78 "/usr/include/netinet/in.h" 2 3


 


extern int bindresvport  (int __sockfd,
		struct sockaddr_in * __sin)  ;

 


# 2 "t2.c" 2

# 1 "/usr/include/stdio.h" 1 3
 



























# 1 "/usr/include/libio.h" 1 3
 























 









# 1 "/usr/include/_G_config.h" 1 3
  











typedef long _G_clock_t;
typedef unsigned short _G_dev_t;
typedef long int _G_fpos_t;
typedef unsigned short _G_gid_t;
typedef unsigned long _G_ino_t;
typedef unsigned short _G_mode_t;
typedef unsigned short _G_nlink_t;
typedef long _G_off_t;
typedef int _G_pid_t;
typedef int _G_ptrdiff_t;
typedef unsigned int _G_sigset_t;
typedef unsigned int _G_size_t;
typedef long _G_time_t;
typedef unsigned short _G_uid_t;
typedef long int _G_wchar_t;
typedef int   _G_int32_t;
typedef unsigned int   _G_uint32_t;
typedef int _G_ssize_t;
typedef void * _G_va_list;
















# 35 "/usr/include/libio.h" 2 3













# 56 "/usr/include/libio.h" 3





































 























 

















 

struct _IO_jump_t;  struct _IO_FILE;

struct _IO_marker {
  struct _IO_marker *_next;
  struct _IO_FILE *_sbuf;
   

   
  int _pos;
# 155 "/usr/include/libio.h" 3

};

struct _IO_FILE {
  int _flags;		 


   
  char* _IO_read_ptr;	 
  char* _IO_read_end;	 
  char* _IO_read_base;	 
  char* _IO_write_base;	 
  char* _IO_write_ptr;	 
  char* _IO_write_end;	 
  char* _IO_buf_base;	 
  char* _IO_buf_end;	 
   
  char *_IO_save_base;  
  char *_IO_backup_base;   
  char *_IO_save_end;  

 




  struct _IO_marker *_markers;
  
  struct _IO_FILE *_chain;
  
  struct _IO_jump_t *_jumps;  
  
  int _fileno;
  int _blksize;
  _G_off_t  _offset;
  

   
  unsigned short _cur_column;
  char _unused;
  char _shortbuf[1];
  
   
};


typedef struct _IO_FILE _IO_FILE;


 



struct _IO_FILE_plus {
  _IO_FILE _file;
  __const void *_vtable;
};

extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;








extern int __underflow  (_IO_FILE*)  ;
extern int __overflow  (_IO_FILE*, int)  ;

extern unsigned __adjust_column  (unsigned start, __const char *line, int count)  ;















extern int _IO_vfscanf  (_IO_FILE*, __const char*, _G_va_list , int*)  ;
extern int _IO_vfprintf  (_IO_FILE*, __const char*, _G_va_list )  ;
extern _G_ssize_t  _IO_padn  (_IO_FILE *, int, _G_ssize_t )  ;
extern _G_size_t  _IO_sgetn  (_IO_FILE *, void*, _G_size_t )  ;

extern void _IO_free_backup_area  (_IO_FILE*)  ;






# 29 "/usr/include/stdio.h" 2 3

























  
# 69 "/usr/include/stdio.h" 3


typedef struct _IO_FILE FILE;
typedef _G_fpos_t  fpos_t;




 








 
extern FILE *stdin, *stdout, *stderr;  





 

extern void clearerr  (FILE*)  ;
extern int fclose  (FILE*)  ;
extern int feof  (FILE*)  ;
extern int ferror  (FILE*)  ;
extern int fflush  (FILE*)  ;
extern int fgetc  (FILE *)  ;
extern int fgetpos  (FILE* fp, fpos_t *pos)  ;
extern char* fgets  (char*, int, FILE*)  ;
extern FILE* fopen  (__const char*, __const char*)  ;
extern int fprintf  (FILE*, __const char* format, ...)  ;
extern int fputc  (int, FILE*)  ;
extern int fputs  (__const char *str, FILE *fp)  ;
extern size_t fread  (void*, size_t, size_t, FILE*)  ;
extern FILE* freopen  (__const char*, __const char*, FILE*)  ;
extern int fscanf  (FILE *fp, __const char* format, ...)  ;
extern int fseek  (FILE* fp, long int offset, int whence)  ;
extern int fsetpos  (FILE* fp, __const fpos_t *pos)  ;
extern long int ftell  (FILE* fp)  ;
extern size_t fwrite  (__const void*, size_t, size_t, FILE*)  ;
extern int getc  (FILE *)  ;
extern int getchar  (void)  ;
extern char* gets  (char*)  ;
extern void perror  (__const char *)  ;
extern int printf  (__const char* format, ...)  ;
extern int putc  (int, FILE *)  ;
extern int putchar  (int)  ;
extern int puts  (__const char *str)  ;
extern int remove  (__const char*)  ;
extern int rename  (__const char* _old, __const char* _new)  ;
extern void rewind  (FILE*)  ;
extern int scanf  (__const char* format, ...)  ;
extern void setbuf  (FILE*, char*)  ;
extern void setlinebuf  (FILE*)  ;
extern void setbuffer  (FILE*, char*, int)  ;
extern int setvbuf  (FILE*, char*, int mode, size_t size)  ;
extern int sprintf  (char*, __const char* format, ...)  ;
extern int sscanf  (__const char* string, __const char* format, ...)  ;
extern FILE* tmpfile  (void)  ;
extern char* tmpnam  (char*)  ;
extern int ungetc  (int c, FILE* fp)  ;
extern int vfprintf  (FILE *fp, char __const *fmt0, _G_va_list)  ;
extern int vprintf  (char __const *fmt, _G_va_list)  ;
extern int vsprintf  (char* string, __const char* format, _G_va_list)  ;


extern FILE *fdopen  (int, __const char *)  ;
extern int fileno  (FILE*)  ;
extern FILE* popen  (__const char*, __const char*)  ;
extern int pclose  (FILE*)  ;



extern int getw  (FILE*)  ;
extern int putw  (int, FILE*)  ;

extern char* tempnam  (__const char *__dir, __const char *__pfx)  ;





extern int sys_nerr;
extern char *sys_errlist[];


extern int _sys_nerr;
extern char *_sys_errlist[];

 

 
extern void psignal  (int __sig, __const char *__s)  ;






extern int __underflow  (struct _IO_FILE*)  ;
extern int __overflow  (struct _IO_FILE*, int)  ;






 


# 3 "t2.c" 2




main()
{
	double tmp;

	tmp = (double) ntohl(1618607871 );
	printf("%f %f %d %d\n",tmp,(double) ntohl(1618607871 ),ntohl(1618607871 ),1618607871 );
}
Technical Details
Message-ID: <9511271426.AA28258@life.ai.mit.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,6873d4a6a198c15,start
X-Google-Attributes: gid113d02,public
From: patc@staff.cs.su.oz.au (Patrick Caldon)
Subject: Bug in 2.7.1 i486-*-linuxaout floating point
Date: 1995/11/27
Message-ID: <9511271426.AA28258@life.ai.mit.edu>
X-Deja-AN: 120236557
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: GNUs Not Usenet
newsgroups: gnu.gcc.bug