This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/31773] New: i suffix on a number always renders up 0.


I had a typo in my code, "id = + 1i" that baffled me as to why it compiled. 
Once I realized that it was legal, I noticed that it was producing the wrong
result (aside from the obvious typo).

It appears that <number><i> always becomes 0 inside gcc.  The cut-and-paste
below is from my computer at my desk at work, but I also tried it on gcc
version 4.1.1 20060525 (Red Hat 4.1.1-1) on a Fedora Core 5 machine, and 
gcc version 3.4.6 [FreeBSD] 20060305 on a FreeBSD 6.2-STABLE machine.


wcolburn@anotherpanda</tmp>$ cat gccbug.c
int main( int argc, char **argv, char **envp )
{
  printf( "0x%x\n", 1i );
  printf( "0x%x\n", (int)1i );
  printf( "0x%x\n", (long)1i );
  printf( "0x%x\n", 99i );
  printf( "0x%x\n", 838475i );
  printf( "0x%x\n", 238485854i );
}
wcolburn@anotherpanda</tmp>$ gcc -v gccbug.c
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
 /usr/libexec/gcc/i386-redhat-linux/3.4.3/cc1 -quiet -v gccbug.c -quiet
-dumpbase gccbug.c -auxbase gccbug -version -o /tmp/wcolburn/ccTwJrT3.s
ignoring nonexistent directory
"/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/3.4.3/include
 /usr/include
End of search list.
GNU C version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) (i386-redhat-linux)
        compiled by GNU C version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as -V -Qy -o /tmp/wcolburn/ccmJTanZ.o /tmp/wcolburn/ccTwJrT3.s
GNU assembler version 2.15.92.0.2 (i386-redhat-linux) using BFD version
2.15.92.0.2 20040927
 /usr/libexec/gcc/i386-redhat-linux/3.4.3/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crt1.o
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crti.o
/usr/lib/gcc/i386-redhat-linux/3.4.3/crtbegin.o
-L/usr/lib/gcc/i386-redhat-linux/3.4.3 -L/usr/lib/gcc/i386-redhat-linux/3.4.3
-L/usr/lib/gcc/i386-redhat-linux/3.4.3/../../.. /tmp/wcolburn/ccmJTanZ.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/i386-redhat-linux/3.4.3/crtend.o
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crtn.o
wcolburn@anotherpanda</tmp>$ ./a.out
0x0
0x0
0x0
0x0
0x0
0x0
wcolburn@anotherpanda</tmp>$ uname -a
Linux anotherpanda.pmc.com 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005
i686 i686 i386 GNU/Linux
wcolburn@anotherpanda</tmp>$

I looked for this as a known bug, but I didn't find it.  If it is known, I'm
just an idiot.  :)


-- 
           Summary: i suffix on a number always renders up 0.
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schlake+gccbug at nmt dot edu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]