where is the string literal allocated ? On the stack ?
Matthew Woehlke
mw_triad@users.sourceforge.net
Fri Apr 20 21:41:00 GMT 2007
Rask Ingemann Lambertsen wrote:
> On Fri, Apr 20, 2007 at 10:54:14AM -0500, Matthew Woehlke wrote:
>> Right, it lives in one of the read-only segments. As noted in my other
>> message it can't live on the stack or foo() would be broken, and it
>> isn't (except for the return type missing the 'const' qualifier which is
>> VERY broken).
>
> GCC used to have -fwritable-strings, but this option was removed for GCC
> 4.0.
And thank the GNU for that! -fwrite-strings was an abomination that only
existed to support broken code. (Some of which I had to un-break... one
of the products I work on *relied* on it until I unilaterally decided we
needed to stop doing that*. Sigh, the joys of code written before
'const' was standardized.)
(* IIRC the fact that it was deprecated meant that people weren't
inclined to disagree with the decision :-). And now, indeed, it *is*
gone, so I'm on solid footing backing it up as the /right/ decision even
without the technical reasons.)
--
Matthew
<insert bad pun... on second thought, better not>
More information about the Gcc-help
mailing list