🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Darrell Tangman Fri, 04 Sep 1992 14:08
volatile and longjmp
#1067
Author: Darrell Tangman
Date: Fri, 04 Sep 1992 14:08
38 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads