@MichaelWojcik said:
@Reweave said:@joe.edwards@imaginuity.com said:
Can you dereference a void pointer like that (especially an uninitialized one)? This looks like the infamous "undefined behavior" I'm always hearing about.
You can't, which is why the compiler throws an error, there's no undefined behavior here.
Dereferencing a pointer-to-void has implicitly undefined behavior, because of the definition of the indirection operator. ISO 9899-1999 6.5.3.2 #4, which defines the result of the * operator, only covers pointer-to-function and pointer-to-object types as operands. "void *" is an incomplete pointer type, so it is neither, so the behavior is not defined.
Shows what I know. I thought it was not valid, thanks for correcting.