From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23060 invoked by alias); 4 Mar 2005 17:05:33 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 22995 invoked by uid 48); 4 Mar 2005 17:05:22 -0000 Date: Fri, 04 Mar 2005 17:05:00 -0000 From: "gary at intrepid dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20050304170516.20319.gary@intrepid.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/20319] New: -fkeep-static-consts with -O asserted doesn't keep consts X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg00541.txt.bz2 List-Id: 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