Article View: gnu.gcc.bug
Article #1067volatile and longjmp
From: Darrell Tangman
Date: Fri, 04 Sep 1992 14:08
Date: Fri, 04 Sep 1992 14:08
38 lines
2118 bytes
2118 bytes
The following code sequence fails on the Motorola 88K when compiled
with gcc 2.2.2 with options "-O -g -funsigned-char"; it has not been
tested without "-g -funsigned-char". Without "-O" the code sequence
executes as expected. If fail_msg is declared static the code
sequence executes as expected.
volatile char *fail_msg ;
if (setjmp (regexpfail)) {
sprintf (msg, "%s\n (%s)", fail_msg, regexp_errmsg) ;
WriteErr (5, "EvalINDEX", msg, DO_PRINT_UNIT) ;
operand[0].val.value.integer_value = 0 ;
} else {
fail_msg = "Incorrectly formed search argument." ;
regbuff = CompileRegexp (srch) ;
fail_msg = "Error occurred while searching." ;
if (regexec (regbuff, src->chars) == 0)
.
.
.
}
The functions CompileRegexp and regexec both longjmp to regexpfail
when they encounter errors. When this code is compiled with the
"-O" option, it appears that the first store to fail_msg is deleted;
if the longjmp is executed from CompileRegexp, the value in fail_msg
is not a pointer to the specified string. This violates the specifi-
cation that "at every sequence point the value of the object in storage
shall agree with that prescribed by the abstract machine" (describing
an object with a type that includes the volatile type specifier) in
our copy of the July 9, 1986, Draft Proposed American National Standard
for Information Systems -- Programming Language C (3.5.2.4, const and
volatile). Unfortunately, we do not have anything later than the 1986
draft; I offer my apologies if this statement has disappeared.
--
Darrell Tangman -- darrell@galois.NSCF.org
National Mathematics Center / National Science Center Foundation, Inc.
P.O. Box 15577, Augusta, GA, USA, 30919-1577
Technical Details
Message-ID:
<9209042208.AA08767@Galois.NSCF.Org>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!galois.nscf.org!darrellShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!galois.nscf.org!darrell From: darrell@galois.nscf.org (Darrell Tangman) Subject: volatile and longjmp Message-ID: <9209042208.AA08767@Galois.NSCF.Org> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 4 Sep 1992 14:08:23 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 39