O
Old Wolf
Is there undefined behaviour here:
#include <stdlib.h>
int main()
{
short *p = malloc( sizeof *p );
long *q = (long *)p;
q;
return 0;
}
Rationale being that evaluating q causes undefined
behaviour because q is neither null, nor pointing to storage
suitable for an object of type *q.
Assuming so; then is it undefined before the `q;' line, or
is the code valid and q indeterminate?
#include <stdlib.h>
int main()
{
short *p = malloc( sizeof *p );
long *q = (long *)p;
q;
return 0;
}
Rationale being that evaluating q causes undefined
behaviour because q is neither null, nor pointing to storage
suitable for an object of type *q.
Assuming so; then is it undefined before the `q;' line, or
is the code valid and q indeterminate?