Hacker News new | ask | show | jobs
by Pay08 91 days ago
I'm fairly certain that the C standard doesn't specify that string literals should be placed into .rodata, just that changing mutating them is UB.
1 comments

That's true, the systems where C was created do not have the relevant features, and I would expect they can't even "protect" that text so that although it's UB it would have worked fifty years ago to attempt the mutation whereas today that will segfault on a Unix.
Compilers could choose to not place the literals into .rodata. Honestly, I don't know why it isn't at least an option on modern implementations.