logoalt Hacker News

tomptoday at 12:09 PM1 replyview on HN

Casting to a pointer of incompatible type is UB. The exception is casting to char*.


Replies

amiga386today at 12:53 PM

Tell me why struct* is incompatible with void* when it's such a standard case in C that you don't need a cast:

    struct foo *x = malloc(sizeof(struct foo)); /* malloc returns void* */
Or rather, tell me why the C11 standards committee decided to declare that struct* is incompatible with a void*
show 1 reply