Defect Report #112

Submission Date: 03 Dec 93
Submittor: WG14
Source: Ron Guilmette
ANSI/ISO C Defect report #rfg19:
Subject: Null pointer constants and relational comparisons.
a) Does the following code involve usage which requires a diagnostic from a conforming implementation?
b) Does the following code involve usage which renders the code itself not strictly conforming?
void test (void *vp)
(vp > (void*)0); /*
? */

An integral constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant. If a null pointer constant is assigned to or compared for equality to a pointer, the constant is converted to a pointer of that type.
This last paragraph of subclause seems to suggest that zero-valued integral constant expressions which are cast to void * (and then called null pointer constants) can only be used in assignments and/or equality comparisons, but not in relational comparisons.
(It was probably the Committee's intent to permit such expression to be used in all ways, and in all contexts where any other kind of void * non-lvalued expressions can be used, but the current wording of subclause does not make that fact altogether apparent and unambiguous.)
The code does not require a diagnostic but has undefined behavior, so it renders the translation unit not strictly conforming. Subclause 6.3.8 makes clear that this behavior is undefined.
Previous Defect Report < - > Next Defect Report