A conforming implementation could make string literals modifiable, and (obviously non-portable) code could rely on that. I don't know whether any current compilers do so. I suspect not.

Apart from that, it's not about actually modifying string literals. It's about currently valid (but admittedly sloppy) code that uses a non-const pointer to point to a string literal. It's easy to write such code in a way that a modern conforming C compiler will not warn about.

That kind of code is the reason that this proposed change is not just an obvious no-brainer, and the author is doing research to find out how much of an issue it really is.

As it happens, I think that the next C standard should make string literals const. Any code that depends on the current behavior can still be compiled with C23 or earlier compilers, or with a non-conforming option, or by ignoring non-fatal warnings. And of course any such code can be fixed, but that's not necessarily trivial; making the source code changes can be a very small part of the process.

Any change that can break existing valid code should be approached with caution to determine whether it's worth the cost. And if the answer is yes, that's great.

> That kind of code is the reason that this proposed change is not just an obvious no-brainer

I don't understand your point here: I disagree this is "obvious", and I don't think I've said anything to imply that?

> And of course any such code can be fixed, but that's not necessarily trivial; making the source code changes can be a very small part of the process

In many cases, it's so trivial you can write code to patch the code. Often, the resulting stripped binary will be identical, so you can prove it's not necessary to even test the result! If decision makers can be made to understand that, you can run around most corporate process that makes this sort of thing hard.

I've spent a lot of time fixing horrible old proprietary code to use const because I think it's important: most of the time, it's very easy. I don't deny there are rats nests that require a lot of refactoring to unwind, but that is the exception rather than the rule, in my personal experience.

It will be vanishingly rare that code will need to be modified in a way that actually changes its runtime behavior to tolerate the proposed change.

My point is that the risk of breaking existing code is the only reason not to apply this change to the standard.

My point is also that that's a valid reason to proceed carefully before making the change.

Even if the required source code changes are trivial or automatable, there will still be some variable amount of work required to deploy the changes. For a small program or library, maybe you can just rebuild and deploy. But for some projects, any change requires going through a full round of review, testing, recertification, and so on. For an update to code that controls a medical device or a nuclear reactor, for example, changing the code is the easy part.

I support the proposed change. I also support performing all due diligence before imposing it on all future implementations and C software.

> But for some projects, any change requires going through a full round of review, testing, recertification, and so on.

If the new binary is literally identical to the last one which was passed validation, absolutely zero additional testing is required. It is a waste of resources to retest an identical binary (assuming everything else can be held constant of course, which obviously can't always be the case).

Actually sending our hypothetical refactoring to production would itself be a waste of resources anyway, since the binary is identical... you just skip it, wait for the next real change, and then proceed as usual.

All processes have exceptions, the "binary identical output" is an easy one if your leadership chain is capable of understanding it.

And to be clear, "binary" here could absolutely mean "entire firmware image". The era of reproducible builds is upon us, and it is glorious.

Sure if the new binary is bitwise identical to the old one, there's no need to release it.

But ...

"The era of reproducible builds is upon us"

What about old code built with old toolchains? And what about organizational policies that require a full round of testing for any update? How hard do you think it would be to change such policies?

No doubt there's some software that could easily be modified, recompiled, and released. My point is that there is also some software that can't.

And yes, in those cases the likely solution is to leave the code alone and continue to build it with the old toolchain.

The point is that the proposed change will break existing valid code, and that has a non-zero cost. I support Jens Gustedt's effort to find out just what that cost is before imposing the change. (And again, I hope the change does go into the next edition of the standard.)