Article View: comp.unix.programmer
Article #3672Re: gcc -O2 bug
From: Lawrence Kirby
Date: Fri, 09 Aug 1996 00:00
Date: Fri, 09 Aug 1996 00:00
34 lines
2333 bytes
2333 bytes
In article <4ubogp$e8a@mule1.mindspring.com>
mroot@atl.mindspring.com "Danette & Murray Root" writes:
>On 7 Aug 1996 22:35:57 -0500, mrbig@freeside.fc.net (Mike Big) wrote
>in comp.lang.c:
>
>=>/*
>=>I'v found what I think might be a bug in gcc's optimization. The
>
>That's not a bug, that's the reason for the 'volatile' keyword.
And also sig_atomic_t. What the code actually violates is (ISO 7.7.1.1):
"If the signal occurs other than as the result of calling the abort or
raise function, the behaviour is undefined if the signal handler calls
any function in the standard library other than the signal function
itself (with a first argument corresponding to the signal that caused
the invocation of the handler) or refers to any object with static
storage duration other than by assigning a value to a static storage
duration variable of type volatile sig_atomic_t."
This allows the compiler to optimise the foreground loop without breaking the
standard. As you can see there is very little that you can do in a signal
handler and remain as strictly conforming C. You can perform calculations
using auto variables and notify events/state changes back to the foreground
code through static variables of type volatile sig_atomic_t which the
foreground code has to poll.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID:
<839588744snz@genesis.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4ubnat$75u@freeside.fc.net> <4ubogp$e8a@mule1.mindspring.com>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: Lawrence Kirby <fred@genesis.demon.co.uk> Subject: Re: gcc -O2 bug Date: 1996/08/09 Message-ID: <839588744snz@genesis.demon.co.uk> X-Deja-AN: 173123635 x-nntp-posting-host: genesis.demon.co.uk references: <4ubnat$75u@freeside.fc.net> <4ubogp$e8a@mule1.mindspring.com> x-mail2news-path: genesis.demon.co.uk organization: none reply-to: fred@genesis.demon.co.uk newsgroups: comp.unix.programmer,gnu.gcc.help,comp.os.linux.development.apps,comp.lang.c