[Issue 1875] Dereferencing void pointers is allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 28 06:51:03 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1875
------- Comment #5 from matti.niemenmaa+dbugzilla at iki.fi 2008-02-28 08:51 -------
Which is why I said I was wrong. I realize that.
However, I do think there's a dereference going on - even if it's undone by the
& to the point that the dereference isn't in the resulting binary. "&
(null[x])" is "& *(null + x)" which means that, essentially, "null + x" is
being dereferenced.
Your code is different: that's not a void pointer, it's a type-casted null
pointer.
GCC gives a "warning: dereferencing 'void *' pointer" for the following C code:
#include <stdlib.h>
int main() {
return (int)&NULL[42];
}
Which is all I ask for. Feel free to mark as WONTFIX if you think that's not
going to happen.
--
More information about the Digitalmars-d-bugs
mailing list