[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 ============================================
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.
The expression (char)(q[24] & 0x0ff) is the minimum that triggers the problem. The original problem used a non constant string.
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...
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'???
There was recently a merge with the mainline, can you try this again?
The small test program now works OK. I am starting a full regression test of my system.
Fixed by merge so closing. Will apply a test case for this.