if printf takes a restrict pointer, then what happens in
printf("%s", "%s");
Is the compiler obliged to have 2 copies of the string?
I think the conclusion that was reached eventually was that this was
technically undefined behavior, because the compiler is perfectly allowed
to do something which, in this case, invokes undefined behavior. This
doesn't seem to matter much.
There was some discussion about something closely related to this in
some case involving arguments to sprintf where you could conceivably want
this, and the sense of the committee, if I recall correctly, was that
it's rare enough that people can do the extra work.
The reason printf's format string has to be restrict is this:
union {
char s[4];
int x;
} foo;
strcpy(foo.s, "%n");
printf(foo.s, &foo.x);
You can easily expand this, using longer and more interesting format strings,
into a form where there's a real possibility of something going wrong.
-s