This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
- From: "iains at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 21 Jul 2011 09:06:16 +0000
- Subject: [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
- Auto-submitted: auto-generated
- References: <bug-47997-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47997
--- Comment #21 from Iain Sandoe <iains at gcc dot gnu.org> 2011-07-21 09:05:10 UTC ---
This is indeed a new bug - if there is to be any lengthly deliberation, please
move it to its own PR (against objective-c).
----
calling fix_string_type () on a tree that is already a STRING_CST appears to
break things..
(the size and unit_size fields get screwed up).
... this might be intended [i.e. we should not call the function when we
already have a STRING_CST]
(or indicate a bug elsewhere).
I am assuming the former for now.... ergo, try this:
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 176554)
+++ gcc/objc/objc-act.c (working copy)
@@ -3132,10 +3132,13 @@ objc_build_string_object (tree string)
struct string_descriptor *desc, key;
void **loc;
- /* Prep the string argument. */
- string = fix_string_type (string);
- TREE_SET_CODE (string, STRING_CST);
- length = TREE_STRING_LENGTH (string) - 1;
+ if (TREE_CODE (string) != STRING_CST)
+ {
+ /* Prep the string argument. */
+ string = fix_string_type (string);
+ TREE_SET_CODE (string, STRING_CST);
+ length = TREE_STRING_LENGTH (string) - 1;
+ }
/* The target may have different ideas on how to construct an ObjC string
literal. On Darwin (Mac OS X), for example, we may wish to obtain a