public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gary at intrepid dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/20319] New: -fkeep-static-consts with -O asserted doesn't keep consts
Date: Fri, 04 Mar 2005 17:05:00 -0000	[thread overview]
Message-ID: <20050304170516.20319.gary@intrepid.com> (raw)

Related discussion:
http://gcc.gnu.org/ml/gcc/2005-03/msg00181.html

Given the following,

static char const rcsid[] =
"$Id: f.c,v 5.4 1993/11/09 17:40:15 eggert Exp $";
int main() {}

When compiled with GCC 3.4.3, at -O2, the ident string above will _not_
appear in the executable.  This is apparently expected behavior.

However,
  gcc -fkeep-static-consts -O2 t.c
did not retain the ident string, rcsid, defined above.  Shouldn't
-fkepp-static-consts have ensured that this static constant would appear
in the executable?

The logic in wrapup_global_declarations (toplev.c) doesn't look quite right:

              else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
                       && (optimize || !flag_keep_static_consts 
                           || DECL_ARTIFICIAL (decl))) 
                needed = 0; 

If 'optimize' is asserted above then flag_keep_static_consts will
not be tested.  Perhaps it should read as follows?

                       && ((optimize && !flag_keep_static_consts)

Alternatively, I wonder if flag_keep_static_consts should be tested earlier at a
higher level, for example:

   if (flag_keep_static_consts)
      /* needed */;

but I'm not sure about which of the earlier tests which assert needed = 0;
are mandatory and which are optional.

-- 
           Summary: -fkeep-static-consts with -O asserted doesn't keep
                    consts
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gary at intrepid dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20319


             reply	other threads:[~2005-03-04 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-04 17:05 gary at intrepid dot com [this message]
2005-03-04 18:29 ` [Bug c/20319] " pinskia at gcc dot gnu dot org
2005-03-04 20:24 ` gary at intrepid dot com
2005-03-04 20:33 ` pinskia at gcc dot gnu dot org
2005-03-04 20:42 ` joseph at codesourcery dot com
2005-03-04 21:54 ` gary at intrepid dot com
2005-03-18 16:16 ` gary at intrepid dot com
2005-06-20  3:04 ` pinskia at gcc dot gnu dot org
2005-06-20 23:40 ` gary at intrepid dot com

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=20050304170516.20319.gary@intrepid.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).