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]

target/5169: Bug in pa-risc gcc optimizer



>Number:         5169
>Category:       target
>Synopsis:       Bug in pa-risc gcc optimizer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 21 05:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Klaus Pedersen
>Release:        all - at least from 2.95 and up
>Organization:
>Environment:
HP-UX 11, HP-UX 10.20, gcc 2.95.2, to current snapshot 

For example
gcc -v
Reading specs from /opt/net/local/gcc302/lib/gcc-lib/hppa1.1-hp-hpux11.00/3.0.2/specs
Configured with: ../configure --enable-haifa --with-gnu-as --with-included-gettext --enable-shared --enable-languages=c,c++,f77 --enable-threads=posix --prefix=/opt/net/local/gcc302 --with-local-prefix=/opt/net/local/gcc302
Thread model: posix
gcc version 3.0.2

I have tried a wide selection of HP boxes (thanks to rodrigc@gcc.gnu.org,
who claims that he doesn't have any problems on HP). - from personal
workstations:
HP-UX coicxxx B.11.00 A 9000/785 2014470784 two-user license 
to N-class servers:
HP-UX caswxxx B.11.00 U 9000/800 600309332 unlimited-user license

>Description:
See also bootstrap/3479, closed by rodrigc@gcc.gnu.org
See also target/5107, investigated by Richard.Earnshaw@arm.com

The attached program, which is the reason that it is
impossible to build a cross compiler for ARM on HP-UX
with default CFLAGS=-O2.

Here is the program in all its glory:

----
int main()
{
    int operands[10] = {0, 65536};
    unsigned int val = operands[1];
    unsigned int mask = 0xff;
    int i;

    for (i = 0; i < 25; i++)
      if ((val & (mask << i)) == val)
        break;

    if (i == 0)
      puts("Fail");

    return 0;
}
----

The problem seem to be that "if (i==0)" is always true!

>How-To-Repeat:
Compile and run attached program:
   gcc -O1 hp-bug-1.c
   ./a.out
Everything is OK.

When compiling with -O2:
    gcc -O2 hp-bug-1.c
    ./a.out
the program returns "fail".
>Fix:
Never compile with higher optimizer settings than -O1 :-(
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-c_auto_file; name="hp-bug-1.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="hp-bug-1.c"

aW50IG1haW4oKQp7CiAgICBpbnQgb3BlcmFuZHNbMTBdID0gezAsIDY1NTM2fTsKICAgIHVuc2ln
bmVkIGludCB2YWwgPSBvcGVyYW5kc1sxXTsKICAgIHVuc2lnbmVkIGludCBtYXNrID0gMHhmZjsK
ICAgIGludCBpOwogICAgCiAgICBmb3IgKGkgPSAwOyBpIDwgMjU7IGkrKykKICAgICAgaWYgKCh2
YWwgJiAobWFzayA8PCBpKSkgPT0gdmFsKQogICAgICAgIGJyZWFrOwoKICAgIGlmIChpID09IDAp
CiAgICAgIHB1dHMoIkZhaWwiKTsKCiAgICByZXR1cm4gMDsKfQo=


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