C1X adds a constraint forbidding casts between pointers and floating-point types (previously compile-time undefined). GCC already generates the required diagnostics; I've applied this patch to add a testcase for them.
Index: gcc.dg/c1x-pointer-float-1.c =================================================================== --- gcc.dg/c1x-pointer-float-1.c (revision 0) +++ gcc.dg/c1x-pointer-float-1.c (revision 0) @@ -0,0 +1,28 @@ +/* Test C1X constraint against pointer / floating-point casts. */ +/* { dg-do compile } */ +/* { dg-options "-std=c1x -pedantic-errors" } */ + +void *p; +float f; +double d; +long double ld; +_Complex float cf; +_Complex double cd; +_Complex long double cld; + +void +func (void) +{ + f = (float) p; /* { dg-error "pointer" } */ + d = (double) p; /* { dg-error "pointer" } */ + ld = (long double) p; /* { dg-error "pointer" } */ + cf = (_Complex float) p; /* { dg-error "pointer" } */ + cd = (_Complex double) p; /* { dg-error "pointer" } */ + cld = (_Complex long double) p; /* { dg-error "pointer" } */ + p = (void *) f; /* { dg-error "pointer" } */ + p = (void *) d; /* { dg-error "pointer" } */ + p = (void *) ld; /* { dg-error "pointer" } */ + p = (void *) cf; /* { dg-error "pointer" } */ + p = (void *) cd; /* { dg-error "pointer" } */ + p = (void *) cld; /* { dg-error "pointer" } */ +} Index: ChangeLog =================================================================== --- ChangeLog (revision 177883) +++ ChangeLog (working copy) @@ -1,3 +1,7 @@ +2011-08-18 Joseph Myers <jos...@codesourcery.com> + + * gcc.dg/c1x-pointer-float-1.c: New test. + 2011-08-18 Mikael Morin <mikael.mo...@sfr.fr> PR fortran/50071 -- Joseph S. Myers jos...@codesourcery.com