This is the mail archive of the gcc@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]

Re: Removing -frwitable-strings


On Dec 19, 2003, at 6:56 AM, Paul Koning wrote:

"Joe" == Joe Buck <Joe.Buck@synopsys.COM> writes:

Joe> The answer, I think, is for the compiler never to assume that Joe> there is such a thing as a string constant....

I'm wondering whether it's worth while to spend any energy on this.
Perhaps I'm naive -- but I remember writable string literals from
Fortran-2 where they were universally recognized as a language design
error, which could produce bizarre program misbehavior.  As a result,
I think of any program that depends on writable string literals as
being defective.

So, what's wrong with removing the flag (with a one version lag via
depreciation, if desired -- though I would not push for that) and
letting people fix the bugs that are hidden by this flag, instead?

That may be the right solution, but remember that we're talking about bugs that will be found at runtime, not at compile time. The symptom will be a segfault, perhaps one that only occurs in rarely executed code paths.

I wonder if it might be possible to give people some better diagnostics?
There are warts in the C and C+ type systems that make it legal to write
really dangerous code that will only fail at runtime, but we're perfectly
free to warn about legal and dangerous code.


For C++, for example, it might be a good idea to add -Wwrite-strings
to -Wall.  That's probably less justifiable for C, but in C++ we really
are talking about a conversion that the standard officially says is
deprecated.

--Matt




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