This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"


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

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> 2011-03-05 09:08:29 UTC ---
we don't implement writable strings, but at present we place the ascii in
".const".
it seems that ld is expecting to see constant strings in .cstring (and won't
accept .const as an alternative).
[[ FTR, the Apple compiler places the strings in .data when they are writable
]].

untested patch:

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c (revision 170678)
+++ gcc/config/darwin.c (working copy)
@@ -1536,6 +1536,12 @@ machopic_select_section (tree decl,
       gcc_unreachable ();
     }

+  if (TREE_CODE (decl) == STRING_CST
+      && (MAX ((HOST_WIDE_INT)TREE_STRING_LENGTH (decl),
+              int_size_in_bytes (TREE_TYPE (decl)))
+         == (HOST_WIDE_INT) strlen (TREE_STRING_POINTER (decl)) + 1))
+    return darwin_sections[cstring_section];
+
   /* Darwin weird special cases.  
      a) OBJC Meta-data. */
   if (DECL_P (decl)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]