home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / gcc / bug / 2261 < prev    next >
Encoding:
Text File  |  1992-09-07  |  2.0 KB  |  52 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!galois.nscf.org!darrell
  3. From: darrell@galois.nscf.org (Darrell Tangman)
  4. Subject: volatile and longjmp
  5. Message-ID: <9209042208.AA08767@Galois.NSCF.Org>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Fri, 4 Sep 1992 14:08:23 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 39
  12.  
  13. The following code sequence fails on the Motorola 88K when compiled
  14. with gcc 2.2.2 with options "-O -g -funsigned-char"; it has not been
  15. tested without "-g -funsigned-char".  Without "-O" the code sequence
  16. executes as expected.  If fail_msg is declared static the code
  17. sequence executes as expected.
  18.  
  19.     volatile char    *fail_msg ;
  20.  
  21.     if (setjmp (regexpfail)) {
  22.         sprintf (msg, "%s\n (%s)", fail_msg, regexp_errmsg) ;
  23.         WriteErr (5, "EvalINDEX", msg, DO_PRINT_UNIT) ;
  24.         operand[0].val.value.integer_value = 0 ;
  25.     } else {
  26.         fail_msg = "Incorrectly formed search argument." ;
  27.         regbuff = CompileRegexp (srch) ;
  28.         fail_msg = "Error occurred while searching." ;
  29.         if (regexec (regbuff, src->chars) == 0)
  30.         .
  31.         .
  32.         .
  33.     }
  34.  
  35. The functions CompileRegexp and regexec both longjmp to regexpfail
  36. when they encounter errors.  When this code is compiled with the
  37. "-O" option, it appears that the first store to fail_msg is deleted;
  38. if the longjmp is executed from CompileRegexp, the value in fail_msg
  39. is not a pointer to the specified string.  This violates the specifi-
  40. cation that "at every sequence point the value of the object in storage
  41. shall agree with that prescribed by the abstract machine" (describing
  42. an object with a type that includes the volatile type specifier) in
  43. our copy of the July 9, 1986, Draft Proposed American National Standard
  44. for Information Systems -- Programming Language C (3.5.2.4, const and
  45. volatile).  Unfortunately, we do not have anything later than the 1986
  46. draft; I offer my apologies if this statement has disappeared.
  47. --
  48. Darrell Tangman -- darrell@galois.NSCF.org
  49. National Mathematics Center / National Science Center Foundation, Inc.
  50. P.O. Box 15577, Augusta, GA, USA, 30919-1577
  51.  
  52.