From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16601 invoked by alias); 26 Feb 2008 21:06:22 -0000 Received: (qmail 16453 invoked by uid 48); 26 Feb 2008 21:05:38 -0000 Date: Tue, 26 Feb 2008 21:06:00 -0000 Message-ID: <20080226210538.16452.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/35384] Variables declared as 'static char * avar = "some string";' cannot be modified In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "Quinlan at ACM dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-02/txt/msg02784.txt.bz2 ------- Comment #4 from Quinlan at ACM dot org 2008-02-26 21:05 ------- If the problem is that the char pointer is pointing to a constant value in: static char * avar = "some string"; then perhaps initializing with an array of one string as in this line work: static char * avar = {"some string"}; That approach doesn't work. Converting avar from a pointer to an array like this however does work: static char avar[] = {"some string"}; This provides a simple workaround that we will use for now. The big problem remaining is: There are inconsistent behaviors exhibited in these tests. The previous approach works, but it still is allowing a constant value to be modified. Is this a bug that may be fixed in the future and break our applications, or can we expect the C standard be upgraded at some point to provide for this type of behavior? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35384