🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Edelsohn Wed, 27 Jan 1993 03:17
gcc-2.3.3 optimization bug on RS/6000
#1662
Author: David Edelsohn
Date: Wed, 27 Jan 1993 03:17
86 lines
3770 bytes
	The following C program produces different results depending on
whether it is compiled with optimization or not.  This code is a fragment
of that found in libg++-2.3's iostream library (sbufvform.C) although it
does not depend on C++ features.  This bug causes libg++-2.3 to work
incorrectly on the RS/6000 architecture.

-----bug.c-----
#include <stdio.h>

#define to_digit(c)     ((c) - '0')
#define is_digit(c)     ((unsigned)to_digit(c) <= 9)

main(int argc, char *argv[])
{
        register const char *fmt;
        register int ch;
        register int n;
        int prec;

        fmt = argv[1];

        ch = *fmt++;

        n = 0;
        while (is_digit(ch)) {
                n = 10 * n + to_digit(ch);
                ch = *fmt++;
        }
        prec = n < 0 ? -1 : n;

        printf("%d\n", prec);

        exit(0);
}
-----

contrib% gcc -v bug.c
Reading specs from /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/specs
gcc version 2.3.3
 /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/cpp -lang-c -v -undef
-D__GNUC__=2 -D_IBMR2 -D_AIX -D_AIX32 -D___IBMR2__ -D___AIX__ -D___AIX32__
-D___IBMR2 -D___AIX -D___AIX32 -D__CHAR_UNSIGNED__ bug.c /tmp/ccXTICrx.i
GNU CPP version 2.3.3
 /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/cc1 /tmp/ccXTICrx.i -quiet
-dumpbase bug.c -version -o /tmp/ccXTICrx.s
GNU C version 2.3.3 compiled by GNU C version 2.3.3.
 as -u -o /tmp/ccXTICrx1.o /tmp/ccXTICrx.s
 /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/ld -T512 -H512 -btextro
-bhalt:4 -bnodelcsect /lib/crt0.o
-L/contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3 -L/contrib/lib
/tmp/ccXTICrx1.o /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/libgcc.a -lc
/contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/libgcc.a

contrib% a.out 23
23

contrib% gcc -v -O bug.c
Reading specs from /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/specs
gcc version 2.3.3
 /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/cpp -lang-c -v -undef
-D__GNUC__=2 -D_IBMR2 -D_AIX -D_AIX32 -D___IBMR2__ -D___AIX__ -D___AIX32__
-D___IBMR2 -D___AIX -D___AIX32 -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ bug.c
/tmp/ccXTwDFW.i
GNU CPP version 2.3.3
 /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/cc1 /tmp/ccXTwDFW.i -quiet
-dumpbase bug.c -O -version -o /tmp/ccXTwDFW.s
GNU C version 2.3.3 compiled by GNU C version 2.3.3.
 as -u -o /tmp/ccXTwDFW1.o /tmp/ccXTwDFW.s
 /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/ld -T512 -H512 -btextro
-bhalt:4 -bnodelcsect /lib/crt0.o
-L/contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3 -L/contrib/lib
/tmp/ccXTwDFW1.o /contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/libgcc.a -lc
/contrib/lib/gcc-lib/rs6000-ibm-aix32/2.3.3/libgcc.a

contrib% a.out 23
-1

	I would appreciate receiving any patches developed to fix this bug.

				Thanks, David
===============================================================================
David Edelsohn                                          Dept of Physics
Syracuse Center for Computational Science               201 Physics Bldg
INTERNET: edelsohn@sccs.Syr.EDU                         Syracuse, NY 13244-1130
"The Church doesn't have problems with sex; the world does" -- Vatican official
"A good theory should fit on a T-shirt" -- Astronomer at Jan 1992 AAS meeting
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads