public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16790] New: Integer down cast ignored in larger expression
@ 2004-07-27 22:35 andyb at mathworks dot com
  2004-07-27 22:42 ` [Bug c/16790] " andyb at mathworks dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: andyb at mathworks dot com @ 2004-07-27 22:35 UTC (permalink / raw)
  To: gcc-bugs

GCC sometimes ignores integer down casts in larger expressions
starting around version 3.2.2
In GCC 2.95.4, these same downcasts were honored.

The following code snippet is from file int_ops.c

  y_final_1 = (int16_T)(  (int16_T)(u1 << 1)   * mul_const >> nshift_right);
  y_middle  =             (int16_T)(u1 << 1);
  y_final_2 = (int16_T)(       y_middle        * mul_const >> nshift_right);

A programmer would expect y_final_1 and y_final_2 to have the same values
under all conditions.   This is not true with the GCC version 3.2.2 through
to the current.  

y_final_1 = -16384   0xFFFFC000
y_final_2 =  16384   0x00004000

Same sequence of integer operations produced DIFFERENT result.

Compiler log shown below.  I don't see any place on this bugzilla
page to enter the .i file that the bug writing guidelines demand???
I'm hoping the "Commit" button will ask me to upload it or something!
Cheers,
Andy B

bartletta-linux:> /hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/bin/gcc -v
-save-temps -g3 -O0 -o int_ops ../int_ops.c ; int_ops
Reading specs from
/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: /home/greg/src/gcc-3.4.0/configure
--prefix=/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0
Thread model: posix
gcc version 3.4.0
/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1
-E -quiet -v -dD ../int_ops.c -mtune=pentiumpro -fworking-directory -O0 -o int_ops.i
ignoring nonexistent directory
"/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/include
 /hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/include
End of search list.
 /hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1
-fpreprocessed int_ops.i -quiet -dumpbase int_ops.c -mtune=pentiumpro -auxbase
int_ops -g3 -O0 -version -o int_ops.s
GNU C version 3.4.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128673
 as -V -Qy -o int_ops.o int_ops.s
GNU assembler version 2.12 (i686-pc-linux-gnu) using BFD version 2.12
 /hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/collect2
--eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o int_ops
/usr/lib/crt1.o /usr/lib/crti.o
/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/crtbegin.o
-L/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0
-L/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../..
int_ops.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
/hub/Linux/glibc-2.2.5/i686/apps/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/crtend.o
/usr/lib/crtn.o

-- 
           Summary: Integer down cast ignored in larger expression
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andyb at mathworks dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-08-08 18:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
2004-07-27 22:42 ` [Bug c/16790] " andyb at mathworks dot com
2004-07-27 23:03 ` pinskia at gcc dot gnu dot org
2004-07-27 23:12 ` [Bug c/16790] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
2004-07-27 23:39 ` [Bug middle-end/16790] " pinskia at gcc dot gnu dot org
2004-08-03 21:24 ` cvs-commit at gcc dot gnu dot org
2004-08-07 21:57 ` [Bug middle-end/16790] [3.3/3.4 " cvs-commit at gcc dot gnu dot org
2004-08-07 22:03 ` [Bug middle-end/16790] [3.3 " pinskia at gcc dot gnu dot org
2004-08-08 18:55 ` cvs-commit at gcc dot gnu dot org
2004-08-08 18:57 ` pinskia at gcc dot gnu dot org

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).