public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/12113] New: wrong result for comparison
@ 2003-08-31  0:48 eyal at eyal dot emu dot id dot au
  2003-08-31  1:43 ` [Bug middle-end/12113] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: eyal at eyal dot emu dot id dot au @ 2003-08-31  0:48 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: wrong result for comparison
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eyal at eyal dot emu dot id dot au
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 3.5-tree-ssa 20030829 (merged 20030817)
  GCC host triplet: i686-pc-linux-gnu

[where can I see the definition of the avove triplet items?]

In the following program, the second printf() should print 'if=1'
but prints 'if=0'.

Compile options "-v -g -O0"

The problem was first seen about a week ago in cvs. Full details in
the run log below.

==================================================
eyal@e7:~$ cat /home/eyal/zz.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

static void
test (char *q)
{
        printf ("'%c'\n",         ((char)((*((char *)(q)+(0+24))) & 0x0ff)));
        printf ("if=%d\n", 'I' == ((char)((*((char *)(q)+(0+24))) & 0x0ff)));
}

int main ()
{
        char    *s = "012345678901234567890123I567890";

        test (s);

        return (0);
}
==================================================
eyal@e7:~$ uname -a
Linux e7 2.4.22 #1 Tue Aug 26 08:12:56 EST 2003 i686 unknown
==================================================
eyal@e7:~$ /usr/local/gcc-mudflap/bin/i686-pc-linux-gnu-gcc-3.5-tree-ssa -v -g
-O0 -Wall -o /home/eyal/zz /home/eyal/zz.c
Reading specs from
/data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/specs
Configured with: ../gcc/configure --prefix=/usr/local/gcc-mudflap
--enable-languages=c
Thread model: posix
gcc version 3.5-tree-ssa 20030829 (merged 20030817)
 /data2/usr/local/gcc-mudflap-20030829-203101/bin/../libexec/gcc/i686-pc-linux-gnu/3.5-tree-ssa/cc1 -quiet -v -iprefix /data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/ /home/eyal/zz.c -quiet -dumpbase zz.c -mtune=pentiumpro -auxbase zz -g -O0 -Wall -version -o /tmp/cc1uYL6H.s
ignoring nonexistent directory
"/data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory
"/usr/local/gcc-mudflap/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/include"
ignoring nonexistent directory
"/usr/local/gcc-mudflap/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/include
 /usr/local/include
 /usr/local/gcc-mudflap/include
 /usr/include
End of search list.
GNU C version 3.5-tree-ssa 20030829 (merged 20030817) (i686-pc-linux-gnu)
        compiled by GNU C version 3.5-tree-ssa 20030829 (merged 20030817).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64574
 as -V -Qy -o /tmp/ccKFH6io.o /tmp/cc1uYL6H.s
GNU assembler version 2.12.90.0.1 (i386-linux) using BFD version 2.12.90.0.1
20020307 Debian/GNU Linux
 /data2/usr/local/gcc-mudflap-20030829-203101/bin/../libexec/gcc/i686-pc-linux-gnu/3.5-tree-ssa/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /home/eyal/zz /usr/lib/crt1.o /usr/lib/crti.o /data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/crtbegin.o -L/data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa -L/data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc -L/usr/local/gcc-mudflap/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa -L/data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../.. -L/usr/local/gcc-mudflap/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../.. /tmp/ccKFH6io.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /data2/usr/local/gcc-mudflap-20030829-203101/bin/../lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/crtend.o /usr/lib/crtn.o
============================================
eyal@e7:~$ /home/eyal/zz
'I'
if=0
============================================


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

* [Bug middle-end/12113] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
@ 2003-08-31  1:43 ` pinskia at gcc dot gnu dot org
  2003-09-03 22:17 ` [Bug middle-end/12113] [tree-ssa] " eyal at eyal dot emu dot id dot au
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-31  1:43 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
             Status|UNCONFIRMED                 |NEW
          Component|c                           |middle-end
     Ever Confirmed|                            |1
  GCC build triplet|3.5-tree-ssa 20030829       |
                   |(merged 20030817)           |
   GCC host triplet|i686-pc-linux-gnu           |
           Keywords|                            |wrong-code
           Priority|P2                          |P1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-31 01:43:11
               date|                            |
   Target Milestone|---                         |tree-ssa


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-31 01:43 -------
Triples are defined like i686-..., target is the t

It happens in 20030822 but not in 20030814.
It looks like it is a fold_const problem as it is already changed into a 0 before it changes into 
generic/gimplified.


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

* [Bug middle-end/12113] [tree-ssa] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
  2003-08-31  1:43 ` [Bug middle-end/12113] " pinskia at gcc dot gnu dot org
@ 2003-09-03 22:17 ` eyal at eyal dot emu dot id dot au
  2003-09-07 14:46 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: eyal at eyal dot emu dot id dot au @ 2003-09-03 22:17 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From eyal at eyal dot emu dot id dot au  2003-09-03 22:17 -------
The expression
    (char)(q[24] & 0x0ff)
is the minimum that triggers the problem. The original problem used a non
constant string.


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

* [Bug middle-end/12113] [tree-ssa] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
  2003-08-31  1:43 ` [Bug middle-end/12113] " pinskia at gcc dot gnu dot org
  2003-09-03 22:17 ` [Bug middle-end/12113] [tree-ssa] " eyal at eyal dot emu dot id dot au
@ 2003-09-07 14:46 ` steven at gcc dot gnu dot org
  2003-09-07 15:55 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-09-07 14:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dnovillo at redhat dot com


------- Additional Comments From steven at gcc dot gnu dot org  2003-09-07 14:46 -------
Hmm weird,

If I compile this code,

int main (void)
{
  char *s = "012345678901234567890123I567890";
  printf ("%c\n", (char)(s[24] & 0x000000ff));
  if ('I' ==  (char)(s[24] & 0x0ff))
    return (0);
  else
    abort ();
}

then my .t02.optimized dump looks like this,
                                                                                
;; Function main (main)
;; enabled by -tree-original
                                                                                
                                                                                
{
   char* s = ("012345678901234567890123I567890");
   printf(("%c\n"), (*(s + 24) & '\xffffffff'));
   if (0)
      return <return-value> = 0;
   else
       abort();
                                                                                
}

Note the difference between the two printf lines. 

Also weird that the first s[24] expr is not folded but the second is...


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

* [Bug middle-end/12113] [tree-ssa] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
                   ` (2 preceding siblings ...)
  2003-09-07 14:46 ` steven at gcc dot gnu dot org
@ 2003-09-07 15:55 ` steven at gcc dot gnu dot org
  2003-09-28 10:12 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-09-07 15:55 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From steven at gcc dot gnu dot org  2003-09-07 15:55 -------
After a mini-merge for fold-const.c from mainline, I get:

;; Function main (main)
;; enabled by -tree-original


{
   char* s = ("012345678901234567890123I567890");
   printf(("%c\n"), (*(s + 24) & '\xffffffff'));
   if ((*(s + 24) & '\xffffffff') == 'I')
      return <return-value> = 0;
   else
       abort();
}


This still looks funny to me, but at least it works.  Why can't we deduce that
s[24] == 'I' and why do we change '0x0ff' to '0xffffffff'???


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

* [Bug middle-end/12113] [tree-ssa] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
                   ` (3 preceding siblings ...)
  2003-09-07 15:55 ` steven at gcc dot gnu dot org
@ 2003-09-28 10:12 ` pinskia at gcc dot gnu dot org
  2003-09-28 15:46 ` eyal at eyal dot emu dot id dot au
  2003-09-28 17:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-09-28 10:12 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From pinskia at gcc dot gnu dot org  2003-09-28 06:37 -------
There was recently a merge with the mainline, can you try this again?


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

* [Bug middle-end/12113] [tree-ssa] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
                   ` (4 preceding siblings ...)
  2003-09-28 10:12 ` pinskia at gcc dot gnu dot org
@ 2003-09-28 15:46 ` eyal at eyal dot emu dot id dot au
  2003-09-28 17:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: eyal at eyal dot emu dot id dot au @ 2003-09-28 15:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From eyal at eyal dot emu dot id dot au  2003-09-28 14:21 -------
The small test program now works OK. I am starting a full regression test of my
system.


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

* [Bug middle-end/12113] [tree-ssa] wrong result for comparison
  2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
                   ` (5 preceding siblings ...)
  2003-09-28 15:46 ` eyal at eyal dot emu dot id dot au
@ 2003-09-28 17:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-09-28 17:22 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-09-28 16:12 -------
Fixed by merge so closing.  Will apply a test case for this.


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

end of thread, other threads:[~2003-09-28 16:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-31  0:48 [Bug c/12113] New: wrong result for comparison eyal at eyal dot emu dot id dot au
2003-08-31  1:43 ` [Bug middle-end/12113] " pinskia at gcc dot gnu dot org
2003-09-03 22:17 ` [Bug middle-end/12113] [tree-ssa] " eyal at eyal dot emu dot id dot au
2003-09-07 14:46 ` steven at gcc dot gnu dot org
2003-09-07 15:55 ` steven at gcc dot gnu dot org
2003-09-28 10:12 ` pinskia at gcc dot gnu dot org
2003-09-28 15:46 ` eyal at eyal dot emu dot id dot au
2003-09-28 17:22 ` 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).