I suppose one might increase the likelihood of non-optimization by putting
the dummy field AFTER the copyright string.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of John Gilmore
Sent: Thursday, October 31, 2013 10:55 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Preventing the deletion of unreferenced strings by optimizing
compilers

I wanted to test my notion before presenting it, and it does turn out that
embedding an unreferenced value in a structure (COBOL record) at least one
other element of which is referenced in an executable statement ensures that
that structure will not be deleted.

A PL/I example

declare 1 copyright_block static,
   2 false aligned bit initial('0'b),
   2 true aligned bit initial('1'b),
   2 copyright_text character(38) initial
      ('C copyright 1591 by John Harington, Kt') ;

found = false ;  /* ex hyothesii */
linear_search: do i = lbound(A,1) to h bound(A,1) ;
  . . .
  found = (A(i) = s) ;
  if found then leave ;  /* match? */
  . . .
end linear_search ;

Here the single reference to copyright_block.false in an executable
statement ensures that the structure copyright_block will not be deleted (or
trimmed) by an optimizing compiler.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to