Article View: comp.unix.programmer
Article #3664Re: gcc -O2 bug
From: Orc
Date: Thu, 08 Aug 1996 00:00
Date: Thu, 08 Aug 1996 00:00
19 lines
1324 bytes
1324 bytes
In article <4ubnat$75u@freeside.fc.net>,
Mike Big <mrbig@freeside.fc.net> wrote:
>/*
>I'v found what I think might be a bug in gcc's optimization.
Not a bug; a feature.
Your code is being optimised away; gcc thinks that 'while(flag)'
is always true when you optimize with -O2.
If you convert your flag declaration to 'volatile int flag;' it will
subvert the optimisations. (Check the ANSI standard; the code you've
got is almost the textbook example of why 'volatile' was created.)
____
david parsons \bi/ followups set to the proper place.
\/
Technical Details
Message-ID:
<4udnqu$vv6@pell.pell.chi.il.us>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4ubnat$75u@freeside.fc.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,7d30cae02ba9b089 X-Google-Attributes: gid11318c,public X-Google-Thread: 10c696,7d30cae02ba9b089 X-Google-Attributes: gid10c696,public X-Google-Thread: fc89c,7d30cae02ba9b089 X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,7d30cae02ba9b089 X-Google-Attributes: gid1014db,public From: orc@pell.chi.il.us (Orc) Subject: Re: gcc -O2 bug Date: 1996/08/08 Message-ID: <4udnqu$vv6@pell.pell.chi.il.us> X-Deja-AN: 172986626 references: <4ubnat$75u@freeside.fc.net> followup-to: comp.std.c organization: I *plonk* LA keywords: gcc bug O2 newsgroups: comp.unix.programmer,gnu.gcc.help,comp.os.linux.development.apps,comp.lang.c