https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80409

--- Comment #2 from Pascal Cuoq <pascal_cuoq at hotmail dot com> ---
> it should work even with standard c

Quoting from 7.6.1.1:2

  … the behavior is undefined, except for the following cases:
  * …
  * one type is pointer to void and the other is a pointer to a character type.

Why would the standard say the above, if using void* with any pointer type
worked?

> for an example %p in printf takes a void* but nobody casts it to void* when 
> passing to printf

This does not correspond to my experience. The C programmers I know fall into
two categories:

- C programmers who do not cast printf %p arguments to void*, because it works.
These programmers also write “*(float*)&uint_variable = 1.0f;”, because it
works, and “if (int_variable + 1 < int_variable) printf ("overflow!");”,
because it works.

- C programmers who do cast printf %p arguments to void*.

The good ship “we shouldn't have to document this because it obviously should
work on normal architectures even if the C standard does not say so” sailed
some time in the late nineties.

Reply via email to