I am aware of the fact that the C standard allows string literals with identical content to be stored in different locations, at least that's what I have been told, and what I take away from other posts here on SO, e.g. this or this one. However it strikes me as odd that the equality of location for these literals is not required by the standard, since it would guarantee smaller executables and speed up equality checks on string literals considerably, making them an O(1) operation instead of O(n).
I would like to know what arguments - from an implementers POV - make it appealing to allow the locations of these literals to differ. Do compilers do any kind of optimization to make the saving on comparing the literal's location irrelevant? I am well aware, that doing such a comparison on the location would be useless if you would compare a literal with a variable pointing to a different location containing the same string, but I am trying to understand how people who make the standard look at this.
I can think of arguments why you would not want to do that, e.g. the subtle errors you might introduce, when you make a location based comparison an operation supported by the standard, but I am not entirely satisfied with what I could come up with.
I hope some of you can shed light on this.
Edit 1: First of all thank you for your answers and comments. Beyond that I would like to add some thoughts on some of the answers given:
@hvd: I think this is a problem for the specific additional optimization, not the idea of having a single instance per string literal.
@Shafik: I think your question makes it clear to me why having this set in stone would not allow for a lot of useful usages. It could only be used in code that is limited to the translations unit's scope. Once two files with the same string literal are compiled independently of each other, both would contain their own string literal at their own location. Objects would have to use an external reference or be recompiled every time they are combined with other objects containing the same literal.
I think I am sufficiently convinced that the less strict implementation spec as John Bollinger and FUZxxl suggested is preferable, given how little could be gained by JUST specifying that string literals should exist only once per translation unit.