c/7762: cast problem with gcc-3.2 on x86 architectures

bfkelly@nsa.gov bfkelly@nsa.gov
Thu Aug 29 11:16:00 GMT 2002


>Number:         7762
>Category:       c
>Synopsis:       cast problem with gcc-3.2 on x86 architectures
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 29 11:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     bfkelly@nsa.gov
>Release:        gcc-3.2
>Organization:
>Environment:
% uname -a
Linux catalina 2.4.9-21smp #1 SMP Thu Jan 17 14:01:48 EST 2002 \
  i686 unknown
%
% gcc -v
Reading specs from /u/bfkelly/public/gcc-3.2/Linux-x86/lib/gcc-lib/\
  i686-pc-linux-gnu/3.2/specs
Configured with: ../gcc-3.2/configure --enable-languages=c \
  --prefix=/u/bfkelly/public/gcc-3.2/Linux-x86
Thread model: posix
gcc version 3.2
%
>Description:
/* 
Demonstrates a cast problem with gcc-3.2 on
    i686-pc-linux-gnu
    i386-pc-solaris2.8
but not on other systems tried (SunOS-sparc, OSF1, etc.)

% uname -a
Linux catalina 2.4.9-21smp #1 SMP Thu Jan 17 14:01:48 EST 2002 \
  i686 unknown
%
% gcc -v
Reading specs from /u/bfkelly/public/gcc-3.2/Linux-x86/lib/gcc-lib/\
  i686-pc-linux-gnu/3.2/specs
Configured with: ../gcc-3.2/configure --enable-languages=c \
  --prefix=/u/bfkelly/public/gcc-3.2/Linux-x86
Thread model: posix
gcc version 3.2
%
% gcc -o foo foo.c
% foo
960.000000
960
960.000000
959          ????
%

*/

#include <stdio.h>

int
main()
{
  int n = 128000;

  printf ("%f\n", 128000 * 0.0075);
  printf ("%d\n", (int) (128000 * 0.0075));

  printf ("%f\n", n * 0.0075);
  printf ("%d\n", (int) (n * 0.0075));

  return(0);
}
>How-To-Repeat:
% gcc -o foo foo.c
% foo
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list