public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/5689: optimizer produces wrong code
@ 2002-02-14  6:36 p.van-hoof
  0 siblings, 0 replies; 2+ messages in thread
From: p.van-hoof @ 2002-02-14  6:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5689
>Category:       optimization
>Synopsis:       optimizer produces wrong code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 14 06:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Peter van Hoof
>Release:        3.0.3
>Organization:
Queen's University Belfast
>Environment:
System: Linux archer.pst.qub.ac.uk 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0.3/configure --prefix=/usr/local/gcc3
>Description:

When gcc 3.0.3 is used with a combination of -O2 or -O3 and -funroll-loops,
it produces wrong code leading to a segmentation fault for the program attached.
Changing the constant "9L" in the input to any lower value circumvents the bug.

>How-To-Repeat:

archer.pst.qub.ac.uk> gcc -v -save-temps -ansi -O2 -funroll-loops -Wall test4.c
Reading specs from /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs
Configured with: ../gcc-3.0.3/configure --prefix=/usr/local/gcc3
Thread model: single
gcc version 3.0.3
 /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cpp0 -lang-c -std=c89 -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=3 -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Wall -Acpu=i386 -Amachine=i386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test4.c test4.i
GNU CPP version 3.0.3 (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/local/gcc3/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/include
 /usr/include
End of search list.
 /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cc1 -fpreprocessed test4.i -quiet -dumpbase test4.c -ansi -O2 -Wall -ansi -version -funroll-loops -o test4.s
GNU CPP version 3.0.3 (cpplib) (i386 Linux/ELF)
GNU C version 3.0.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.0.3.
 as --traditional-format -V -Qy -o test4.o test4.s
GNU assembler version 2.10.91 (i386-redhat-linux) using BFD version 2.10.91.0.2
 /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/crtbegin.o -L/usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3 -L/usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/../../.. test4.o -lgcc -lc -lgcc /usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/crtend.o /usr/lib/crtn.o
archer.pst.qub.ac.uk> a.out
Segmentation fault
archer.pst.qub.ac.uk>

Correct behavior would be

archer.pst.qub.ac.uk> gcc -ansi -O2 -Wall test4.c
archer.pst.qub.ac.uk> a.out
archer.pst.qub.ac.uk>

begin 644 test4.i.bz2
M0EIH.3%!62936<8,Z8(``%__@`04!`!8?7PN``0`"K_WWAHP`/@H:B&F@:&@
M```!H&!D&0`&(T&0R`P2*$:4R9DT:C$:::;4]09J?JDDBFYM4J&])(C+7"1$
M@2JT55$T""2$;?(+@X\$ON)Q:=^1D3,ZKL;0RWD`962>-]_<+H@3YG,C>#1L
M-A`SA77TU%=X,+4%D%H+<W&>HQ8S"-EOP2ZMGJ,9X"Z[29BE=91,@26#PA,U
MY_U"Z8H9%"B"P.4OP9[;H]G!:1I<#OTB'9D@4/G4D,B2,L0.!\)C`-RX@2F#
@U*8ICP$P*F$BF&X`RB=!^-QO&,@?XNY(IPH2&,&=,$``
`
end

>Fix:

Using optimization level -O1, or omitting -funroll-loops circumvents the bug.
>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: optimization/5689: optimizer produces wrong code
@ 2002-04-03  2:20 rth
  0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-04-03  2:20 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, p.van-hoof

Synopsis: optimizer produces wrong code

State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Wed Apr  3 02:20:03 2002
State-Changed-Why:
    Fixed for gcc 3.1.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5689


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

end of thread, other threads:[~2002-04-03 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-14  6:36 optimization/5689: optimizer produces wrong code p.van-hoof
2002-04-03  2:20 rth

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).