A
Antoine Leca
I did redirect further discussions toward comp.std.c only.
En (e-mail address removed), Keith Thompson va escriure:
You missed my point.
I was pointing out that specifying a behaviour for fprintf("%p", (void*)0)
would be useless if (because of the symmetry) you did not specify that
fscanf("%p", &p) could make a null pointer to be stored in p.
And I guess while a number of /implementations/ are in fact ready to digest
the first form (as you pointed out), there is also a number of /programs/
that might *not* like receiving a null pointer.
And as you know, programs have priority over implementations.
Sure. I often see them printing "(null)".
However, I am not happy about something like that being incorporated into
the C standard (particularly on 16-bit implementations where "(null)" can
change the alignments of the outputs).
Of course. There are a number of them, probably the majority in fact
(particularly with *printf(), such as the relationship between signed and
unsigned).
Antoine
En (e-mail address removed), Keith Thompson va escriure:
I disagree. I often use "%p" to show the value of a pointer. The
displayed value typically can't be used by the program itself; it's
for my information. Much existing code presumably uses "%p" to
display pointer values that may or may not be null.
You missed my point.
I was pointing out that specifying a behaviour for fprintf("%p", (void*)0)
would be useless if (because of the symmetry) you did not specify that
fscanf("%p", &p) could make a null pointer to be stored in p.
And I guess while a number of /implementations/ are in fact ready to digest
the first form (as you pointed out), there is also a number of /programs/
that might *not* like receiving a null pointer.
And as you know, programs have priority over implementations.
A typical implementation (possibly all implementations) already
supports printf("%p\n", (void*)0) with no extra effort;
Sure. I often see them printing "(null)".
However, I am not happy about something like that being incorporated into
the C standard (particularly on 16-bit implementations where "(null)" can
change the alignments of the outputs).
Even if it were decided that printf("%p\n", (void*)0) invoked
undefined behavior, implementations would continue to behave as they
do now; it would be an instance of UB that's practically never
detected.
Of course. There are a number of them, probably the majority in fact
(particularly with *printf(), such as the relationship between signed and
unsigned).
Antoine