Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: rhel 7 and kforth Date: Tue, 28 Apr 2015 02:03:15 -0400 Organization: Aioe.org NNTP Server Lines: 74 Message-ID: References: <2015Apr20.140504@mips.complang.tuwien.ac.at> <87sibtx8ob.fsf@jester.gateway.sonic.net> <2015Apr22.130001@mips.complang.tuwien.ac.at> <878udhmle2.fsf@jester.gateway.sonic.net> <2015Apr25.184119@mips.complang.tuwien.ac.at> <2015Apr26.165622@mips.complang.tuwien.ac.at> <6f87de3d-bf50-4d21-814b-e106b29cd299@googlegroups.com> <2015Apr27.110253@mips.complang.tuwien.ac.at> <5e7af70a-115a-4b7c-a8ae-7871a8fb6ded@googlegroups.com> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:38674 On Mon, 27 Apr 2015 22:30:43 -0400, wrote: > On Monday, April 27, 2015 at 4:15:37 AM UTC-5, Anton Ertl wrote: >> extern void foo(int a[]); >> >> int main(int argc, char *argv[]) { >> int i, a[16]; >> int x=0; >> do { >> a[i++]=x; >> x+=0x10000000; >> } while (x!=0); >> foo(a); >> return 0; >> } >> >> gcc-4.8.2 miscompiles this into: >> >> ... >> main: >> .LFB24: >> .cfi_startproc >> .p2align 4,,10 >> .p2align 3 >> .L2: >> jmp .L2 >> ... >> >> Do you see why it does this? >> > ... > > I'm having trouble understanding why the compiler does this. To avoid > issues of initialization and such, I modified the example as follows: > > int main() > { > int i=0, a[16]; > int x=0; > do { > a[i++] = x; > x += 1; > } while (x != 0 ); > printf("%d\n", a[0]); > return 0; > } > > > gcc v 4.9.x generates the following, with -S -Wall -O3 : > : > main: > .LFB0: > .cfi_startproc > .p2align 4,,10 > .p2align 3 > .L2: > jmp .L2 > .cfi_endproc > : > Anton said "gcc-4.8.2" introduced this error, but I'm seeing it for much older GCC versions too. GCC 3.4.1 (DOS 32-bit) does not generate an infinite loop for any optimization level. GCC 4.1.0 (DOS 32-bit) and GCC 4.7.2 (Linux 64-bit) generate an infinite loop for -O2 and -O3 levels. So, the issue is likely with the entire GCC 4.x series with -O2 optimization or higher. Rod Pemberton -- Cars kill more people than guns in the U.S. Yet, no one is trying to take away your car.