public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* other/10181: wrong conversion [unsigned -> double] with [-masm=intel]
@ 2003-03-21 13:26 markus.mauhart
  0 siblings, 0 replies; only message in thread
From: markus.mauhart @ 2003-03-21 13:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10181
>Category:       other
>Synopsis:       wrong conversion [unsigned -> double] with [-masm=intel]
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 21 13:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     markus.mauhart@chello.at
>Release:        gcc version 3.2 20020927 (prerelease)
>Organization:
>Environment:
cygwin under winXP, AMD Duron
>Description:
When using option "-masm=intel", then all conversions from unsigned u (with u>=0x8000 (32768)) to double fail. One effect then is that all conversions from "[U]LONGLONG" to double fail for x>0x8000.
This is with C and C++ code.
>How-To-Repeat:
Compile 123.c like ...
   gcc -v -save-temps -masm=intel -o 123.exe -g 123.c
... and then run 123.exe: it then displays correct conversions (all signed -> double) and incorrect conversions (all unsigned>=32768)

//file 123.c
#include <stdio.h>

int main (int x,char const* const y[])
    {
    unsigned int u = 0x4000		;
    for ( ;u ;u*=2)
	{
	int	i			;
	double	du			;
	double	di			;

	i = --u , du = u , di = i	;
	printf ("u=% 8x, double(u)=% 14.1f, i=int(u)=% 11i, double(i)=% 14.1f\n"
		,u ,du ,i ,di)		;

	i = ++u , du = u , di = i	;
	printf ("u=% 8x, double(u)=% 14.1f, i=int(u)=% 11i, double(i)=% 14.1f\n"
		,u ,du ,i ,di)		;
	}
    return 0				;
    }
>Fix:
AFAIK the only workaround is to remove the option [-masm=intel]
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="123.i"
Content-Disposition: inline; filename="123.i"

# 1 "123.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "123.c"
# 1 "/usr/include/stdio.h" 1 3
# 29 "/usr/include/stdio.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 15 "/usr/include/_ansi.h" 3
# 1 "/usr/include/newlib.h" 1 3
# 16 "/usr/include/_ansi.h" 2 3
# 1 "/usr/include/sys/config.h" 1 3



# 1 "/usr/include/machine/ieeefp.h" 1 3
# 5 "/usr/include/sys/config.h" 2 3
# 17 "/usr/include/_ansi.h" 2 3
# 30 "/usr/include/stdio.h" 2 3




# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 203 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef unsigned int size_t;
# 35 "/usr/include/stdio.h" 2 3


# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stdarg.h" 1 3
# 44 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stdarg.h" 3
typedef __builtin_va_list __gnuc_va_list;
# 38 "/usr/include/stdio.h" 2 3







# 1 "/usr/include/sys/reent.h" 1 3
# 14 "/usr/include/sys/reent.h" 3
# 1 "/usr/include/sys/_types.h" 1 3
# 12 "/usr/include/sys/_types.h" 3
typedef long _off_t;
__extension__ typedef long long _off64_t;


typedef int _ssize_t;





# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 323 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef unsigned int wint_t;
# 23 "/usr/include/sys/_types.h" 2 3


typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;
} _mbstate_t;

typedef int _flock_t;
# 15 "/usr/include/sys/reent.h" 2 3




typedef unsigned long __ULong;
# 40 "/usr/include/sys/reent.h" 3
struct _Bigint
{
  struct _Bigint *_next;
  int _k, _maxwds, _sign, _wds;
  __ULong _x[1];
};


struct __tm
{
  int __tm_sec;
  int __tm_min;
  int __tm_hour;
  int __tm_mday;
  int __tm_mon;
  int __tm_year;
  int __tm_wday;
  int __tm_yday;
  int __tm_isdst;
};
# 68 "/usr/include/sys/reent.h" 3
struct _atexit {
        struct _atexit *_next;
        int _ind;
        void (*_fns[32])(void);
        void *_fnargs[32];
        __ULong _fntypes;
};
# 91 "/usr/include/sys/reent.h" 3
struct __sbuf {
        unsigned char *_base;
        int _size;
};






typedef long _fpos_t;
# 156 "/usr/include/sys/reent.h" 3
struct __sFILE {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;






  void * _cookie;

  _ssize_t __attribute__((__cdecl__)) (*_read) (void * _cookie, char *_buf, int _n);
  _ssize_t __attribute__((__cdecl__)) (*_write) (void * _cookie, const char *_buf, int _n);

  _fpos_t __attribute__((__cdecl__)) (*_seek) (void * _cookie, _fpos_t _offset, int _whence);
  int __attribute__((__cdecl__)) (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _offset;


  struct _reent *_data;



  _flock_t _lock;

};
# 249 "/usr/include/sys/reent.h" 3
typedef struct __sFILE __FILE;


struct _glue
{
  struct _glue *_next;
  int _niobs;
  __FILE *_iobs;
};
# 280 "/usr/include/sys/reent.h" 3
struct _rand48 {
  unsigned short _seed[3];
  unsigned short _mult[3];
  unsigned short _add;




};
# 532 "/usr/include/sys/reent.h" 3
struct _reent
{
  int _errno;




  __FILE *_stdin, *_stdout, *_stderr;

  int _inc;
  char _emergency[25];

  int _current_category;
  const char *_current_locale;

  int __sdidinit;

  void __attribute__((__cdecl__)) (*__cleanup) (struct _reent *);


  struct _Bigint *_result;
  int _result_k;
  struct _Bigint *_p5s;
  struct _Bigint **_freelist;


  int _cvtlen;
  char *_cvtbuf;

  union
    {
      struct
        {
          unsigned int _unused_rand;
          char * _strtok_last;
          char _asctime_buf[26];
          struct __tm _localtime_buf;
          int _gamma_signgam;
          __extension__ unsigned long long _rand_next;
          struct _rand48 _r48;
          _mbstate_t _mblen_state;
          _mbstate_t _mbtowc_state;
          _mbstate_t _wctomb_state;
          char _l64a_buf[8];
          char _signal_buf[24];
          int _getdate_err;
          _mbstate_t _mbrlen_state;
          _mbstate_t _mbrtowc_state;
          _mbstate_t _mbsrtowcs_state;
          _mbstate_t _wcrtomb_state;
          _mbstate_t _wcsrtombs_state;
        } _reent;



      struct
        {

          unsigned char * _nextf[30];
          unsigned int _nmalloc[30];
        } _unused;
    } _new;


  struct _atexit *_atexit;
  struct _atexit _atexit0;


  void (**(_sig_func))(int);




  struct _glue __sglue;
  __FILE __sf[3];
};
# 728 "/usr/include/sys/reent.h" 3
extern struct _reent *_impure_ptr ;

void _reclaim_reent (struct _reent *);
# 46 "/usr/include/stdio.h" 2 3
# 1 "/usr/include/sys/types.h" 1 3
# 24 "/usr/include/sys/types.h" 3
typedef short int __int16_t;
typedef unsigned short int __uint16_t;





typedef int __int32_t;
typedef unsigned int __uint32_t;






__extension__ typedef long long __int64_t;
__extension__ typedef unsigned long long __uint64_t;
# 59 "/usr/include/sys/types.h" 3
# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 1 3
# 149 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef int ptrdiff_t;
# 296 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3
typedef short unsigned int wchar_t;
# 60 "/usr/include/sys/types.h" 2 3
# 1 "/usr/include/machine/types.h" 1 3
# 36 "/usr/include/machine/types.h" 3
typedef long int __off_t;
typedef int __pid_t;

__extension__ typedef long long int __loff_t;
# 61 "/usr/include/sys/types.h" 2 3
# 82 "/usr/include/sys/types.h" 3
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;



typedef unsigned short ushort;
typedef unsigned int uint;



typedef unsigned long clock_t;




typedef long time_t;




struct timespec {
  time_t tv_sec;
  long tv_nsec;
};

struct itimerspec {
  struct timespec it_interval;
  struct timespec it_value;
};


typedef long daddr_t;
typedef char * caddr_t;


typedef unsigned long ino_t;
# 130 "/usr/include/sys/types.h" 3
typedef unsigned long vm_offset_t;
typedef unsigned long vm_size_t;



typedef char int8_t;
typedef unsigned char u_int8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;
typedef int32_t register_t;
# 169 "/usr/include/sys/types.h" 3
typedef int pid_t;
typedef long key_t;
typedef _ssize_t ssize_t;


typedef char * addr_t;
typedef int mode_t;
# 188 "/usr/include/sys/types.h" 3
typedef unsigned short nlink_t;
# 210 "/usr/include/sys/types.h" 3
typedef long fd_mask;







typedef struct _types_fd_set {
        fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof (fd_mask) * 8)))];
} _types_fd_set;
# 246 "/usr/include/sys/types.h" 3
typedef unsigned long clockid_t;




typedef unsigned long timer_t;




typedef long useconds_t;


# 1 "/usr/include/sys/features.h" 1 3
# 260 "/usr/include/sys/types.h" 2 3
# 364 "/usr/include/sys/types.h" 3
# 1 "/usr/include/cygwin/types.h" 1 3
# 20 "/usr/include/cygwin/types.h" 3
# 1 "/usr/include/sys/sysmacros.h" 1 3
# 21 "/usr/include/cygwin/types.h" 2 3

typedef struct timespec timespec_t, timestruc_t;

typedef long __off32_t;
typedef long long __off64_t;



typedef __off32_t off_t;


typedef short __dev16_t;
typedef unsigned long __dev32_t;



typedef __dev16_t dev_t;


typedef long blksize_t;

typedef long __blkcnt32_t;
typedef long long __blkcnt64_t;



typedef __blkcnt32_t blkcnt_t;


typedef unsigned short __uid16_t;
typedef unsigned short __gid16_t;
typedef unsigned long __uid32_t;
typedef unsigned long __gid32_t;




typedef __uid16_t uid_t;
typedef __gid16_t gid_t;




typedef struct __pthread_t {char __dummy;} *pthread_t;
typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;

typedef struct __pthread_key_t {char __dummy;} *pthread_key_t;
typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t;
typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t;
typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t;


typedef struct
{
  pthread_mutex_t mutex;
  int state;
}
pthread_once_t;
typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t;
typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t;
# 365 "/usr/include/sys/types.h" 2 3
# 47 "/usr/include/stdio.h" 2 3



typedef _fpos_t fpos_t;
typedef __FILE FILE;





# 1 "/usr/include/sys/stdio.h" 1 3
# 58 "/usr/include/stdio.h" 2 3
# 162 "/usr/include/stdio.h" 3
FILE * __attribute__((__cdecl__)) tmpfile (void);
char * __attribute__((__cdecl__)) tmpnam (char *);
int __attribute__((__cdecl__)) fclose (FILE *);
int __attribute__((__cdecl__)) fflush (FILE *);
FILE * __attribute__((__cdecl__)) freopen (const char *, const char *, FILE *);
void __attribute__((__cdecl__)) setbuf (FILE *, char *);
int __attribute__((__cdecl__)) setvbuf (FILE *, char *, int, size_t);
int __attribute__((__cdecl__)) fprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) fscanf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) printf (const char *, ...);
int __attribute__((__cdecl__)) scanf (const char *, ...);
int __attribute__((__cdecl__)) sscanf (const char *, const char *, ...);
int __attribute__((__cdecl__)) vfprintf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vprintf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsprintf (char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) fgetc (FILE *);
char * __attribute__((__cdecl__)) fgets (char *, int, FILE *);
int __attribute__((__cdecl__)) fputc (int, FILE *);
int __attribute__((__cdecl__)) fputs (const char *, FILE *);
int __attribute__((__cdecl__)) getc (FILE *);
int __attribute__((__cdecl__)) getchar (void);
char * __attribute__((__cdecl__)) gets (char *);
int __attribute__((__cdecl__)) putc (int, FILE *);
int __attribute__((__cdecl__)) putchar (int);
int __attribute__((__cdecl__)) puts (const char *);
int __attribute__((__cdecl__)) ungetc (int, FILE *);
size_t __attribute__((__cdecl__)) fread (void *, size_t _size, size_t _n, FILE *);
size_t __attribute__((__cdecl__)) fwrite (const void * , size_t _size, size_t _n, FILE *);
int __attribute__((__cdecl__)) fgetpos (FILE *, fpos_t *);
int __attribute__((__cdecl__)) fseek (FILE *, long, int);
int __attribute__((__cdecl__)) fsetpos (FILE *, const fpos_t *);
long __attribute__((__cdecl__)) ftell ( FILE *);
void __attribute__((__cdecl__)) rewind (FILE *);
void __attribute__((__cdecl__)) clearerr (FILE *);
int __attribute__((__cdecl__)) feof (FILE *);
int __attribute__((__cdecl__)) ferror (FILE *);
void __attribute__((__cdecl__)) perror (const char *);

FILE * __attribute__((__cdecl__)) fopen (const char *_name, const char *_type);
int __attribute__((__cdecl__)) sprintf (char *, const char *, ...);
int __attribute__((__cdecl__)) remove (const char *);
int __attribute__((__cdecl__)) rename (const char *, const char *);


int __attribute__((__cdecl__)) asprintf (char **, const char *, ...);
int __attribute__((__cdecl__)) fseeko (FILE *, off_t, int);
off_t __attribute__((__cdecl__)) ftello ( FILE *);
int __attribute__((__cdecl__)) vfiprintf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) iprintf (const char *, ...);
int __attribute__((__cdecl__)) fiprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) siprintf (char *, const char *, ...);
char * __attribute__((__cdecl__)) tempnam (const char *, const char *);
int __attribute__((__cdecl__)) vasprintf (char **, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsnprintf (char *, size_t, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vfscanf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vscanf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsscanf (const char *, const char *, __gnuc_va_list);

int __attribute__((__cdecl__)) fcloseall (void);
int __attribute__((__cdecl__)) snprintf (char *, size_t, const char *, ...);
# 231 "/usr/include/stdio.h" 3
FILE * __attribute__((__cdecl__)) fdopen (int, const char *);

int __attribute__((__cdecl__)) fileno (FILE *);
int __attribute__((__cdecl__)) getw (FILE *);
int __attribute__((__cdecl__)) pclose (FILE *);
FILE * __attribute__((__cdecl__)) popen (const char *, const char *);
int __attribute__((__cdecl__)) putw (int, FILE *);
void __attribute__((__cdecl__)) setbuffer (FILE *, char *, int);
int __attribute__((__cdecl__)) setlinebuf (FILE *);
int __attribute__((__cdecl__)) getc_unlocked (FILE *);
int __attribute__((__cdecl__)) getchar_unlocked (void);
void __attribute__((__cdecl__)) flockfile (FILE *);
int __attribute__((__cdecl__)) ftrylockfile (FILE *);
void __attribute__((__cdecl__)) funlockfile (FILE *);
int __attribute__((__cdecl__)) putc_unlocked (int, FILE *);
int __attribute__((__cdecl__)) putchar_unlocked (int);






int __attribute__((__cdecl__)) _asprintf_r (struct _reent *, char **, const char *, ...);
int __attribute__((__cdecl__)) _fcloseall_r (struct _reent *);
FILE * __attribute__((__cdecl__)) _fdopen_r (struct _reent *, int, const char *);
FILE * __attribute__((__cdecl__)) _fopen_r (struct _reent *, const char *, const char *);
int __attribute__((__cdecl__)) _fscanf_r (struct _reent *, FILE *, const char *, ...);
int __attribute__((__cdecl__)) _getchar_r (struct _reent *);
char * __attribute__((__cdecl__)) _gets_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _iprintf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _mkstemp_r (struct _reent *, char *);
char * __attribute__((__cdecl__)) _mktemp_r (struct _reent *, char *);
void __attribute__((__cdecl__)) _perror_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _printf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _putchar_r (struct _reent *, int);
int __attribute__((__cdecl__)) _puts_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _remove_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _rename_r (struct _reent *, const char *_old, const char *_new);

int __attribute__((__cdecl__)) _scanf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _sprintf_r (struct _reent *, char *, const char *, ...);
int __attribute__((__cdecl__)) _snprintf_r (struct _reent *, char *, size_t, const char *, ...);
int __attribute__((__cdecl__)) _sscanf_r (struct _reent *, const char *, const char *, ...);
char * __attribute__((__cdecl__)) _tempnam_r (struct _reent *, const char *, const char *);
FILE * __attribute__((__cdecl__)) _tmpfile_r (struct _reent *);
char * __attribute__((__cdecl__)) _tmpnam_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vprintf_r (struct _reent *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsprintf_r (struct _reent *, char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsnprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vscanf_r (struct _reent *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list);

ssize_t __attribute__((__cdecl__)) __getdelim (char **, size_t *, int, FILE *);
ssize_t __attribute__((__cdecl__)) __getline (char **, size_t *, FILE *);
# 309 "/usr/include/stdio.h" 3
int __attribute__((__cdecl__)) __srget (FILE *);
int __attribute__((__cdecl__)) __swbuf (int, FILE *);






FILE *__attribute__((__cdecl__)) funopen (const void * _cookie, int (*readfn)(void * _cookie, char *_buf, int _n), int (*writefn)(void * _cookie, const char *_buf, int _n), fpos_t (*seekfn)(void * _cookie, fpos_t _off, int _whence), int (*closefn)(void * _cookie));
# 334 "/usr/include/stdio.h" 3
static __inline__ int __sgetc(FILE *__p)
  {
    int __c = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
    if ((__p->_flags & 0x4000) && (__c == '\r'))
      {
      int __c2 = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
      if (__c2 == '\n')
        __c = __c2;
      else
        ungetc(__c2, __p);
      }
    return __c;
  }
# 416 "/usr/include/stdio.h" 3

# 2 "123.c" 2

int main (int x,char const* const y[])
    {
    unsigned int u = 0x4000 ;
    for ( ;u ;u*=2)
        {
        int i ;
        double du ;
        double di ;

        i = --u , du = u , di = i ;
        printf ("u=% 8x, double(u)=% 14.1f, i=int(u)=% 11i, double(i)=% 14.1f\n"
                ,u ,du ,i ,di) ;

        i = ++u , du = u , di = i ;
        printf ("u=% 8x, double(u)=% 14.1f, i=int(u)=% 11i, double(i)=% 14.1f\n"
                ,u ,du ,i ,di) ;
        }
    return 0 ;
    }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-21 13:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-21 13:26 other/10181: wrong conversion [unsigned -> double] with [-masm=intel] markus.mauhart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).