Document:WG14 N1187
Date: 2006-08-29
Author: Fred J. Tydeman

Possible Defect Report: Casts between pointer types and floating-point types.

Consider the code:

int main(void){
  long double ld = 1.L;
  double d = 1.0;
  float f = 1.f;
  void * pv;
  char * pc;

  pv = (void *)ld;
  pc = (char *)d;
  f = (float)pv;
  d = (double)pc;

  return 0;
}

Question: What is the semantics of casts between pointer types and floating-point types?

6.5.4 Cast operators, in constraints, has:

Unless the type name specifies a void type, the type name shall specify qualified or unqualified scalar type and the operand shall have scalar type.

[So the above code is valid from a syntax standpoint.]

6.3.2.3 Pointers, paragraphs 5 and 6 discusss conversions between pointer types and integer types. [May be undefined, may be trap representation.]

Nowhere can I find any discussion of conversions between pointer types and floating-point types (real, complex, and/or imaginary).

I do not care what the answer is. This case can be made a constraint violation, undefined, unspecifed, implemetation-defined, or treated as if it was converted via some integer type during the process. We should add words to the Rationale on why this case was done as it is.