public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Brown <david@eckhardttrading.com>
To: gcc-help@gcc.gnu.org
Subject: force the (gfortran) compiler to not optimize out a variable
Date: Thu, 28 Jul 2022 09:24:30 -0500	[thread overview]
Message-ID: <CAEBUjhP3ef6EznNOeqrQPCzVOJ=ootDea_sir5ZgmtdC7X6_vg@mail.gmail.com> (raw)

To be able to easily identify the version of an executable binary, we embed
a version string in the code, i.e.
character(len=64)   :: vers='<<<vers_bltr4_1.1.0.0>>>'//achar(0)
...
character(len=256) c256

and then use the strings command to (we're running redhat) to be able to
quickly identify the version of the executable, i.e.
[db@VI1 src]$ strings ../bin/bltr4.exe | grep "<<<ver"
<<<vers_bltr4_1.1.0.0>>>

The only problem is that to make sure the variable vers does not get
optimized out by the compiler, I have to include code like this
c256=vers    !needed so version string does not get optimized out by
compiler

We do need to make sure the code is optimized, but having to include that
above assignment statement is not only somewhat obtuse but in some edge
cases chews up resources (some of the programs are very time/resource
sensitive).  I've tried various work arounds, but in summary the above
assignment seems to be the only way to insure the compiler does not
optimize out the vers string.

Is there any way to force the compiler to keep a variable in the
executable, yet otherwise have the optimizer on?

Thanks in advance

David





-- 
David Brown
Eckhardt Trading Company
300 S. Wacker Drive, Suite 1080
Chicago, IL 60606
Tel:  312-765-0565 x1006

-- 


PAST PERFORMANCE IS NOT
NECESSARILY INDICATIVE OF FUTURE RESULTS.



This 
message (including
any attachments) contains confidential information 
intended for a specific individual
and purpose and is protected by law. Any 
use, distribution, disclosure, alteration,
copying or re-transmittal by 
persons who are not intended recipients of this
email may be a violation of 
law and is strictly prohibited. If you are not the
intended recipient, 
please permanently delete all copies of this e-mail and any
attachments 
from your computer system and destroy any hard copies. This e-mail
and any 
attachments hereto are for informational purposes only and should not
be 
construed as an offer to provide advisory services, or sell interests in 
any
investment vehicle managed, by the Trading Advisor or its affiliates. 
Any
information regarding trading performance must be considered in 
conjunction
with the appropriate disclosure documents.

                 reply	other threads:[~2022-07-28 14:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEBUjhP3ef6EznNOeqrQPCzVOJ=ootDea_sir5ZgmtdC7X6_vg@mail.gmail.com' \
    --to=david@eckhardttrading.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).