extern void v; void f(void) { &v; } is invalid in both C90 and C99: lvalues cannot have type void, although they can have types const void or volatile void, and none of the other possibilities for operands on '&' are met. However, GCC fails to diagnose this code.
extern void *p; void f(void) { &*p; } is invalid in C90 (for the same reason) but valid in C99 because the result of a '*' operator is a permitted operand for '&' in C99 even if not an lvalue. GCC gives a warning "dereferencing 'void *' pointer", but not an error with -pedantic-errors. In C90 mode, but not in C99 mode, the use of '&' in this code should receive a pedwarn. See also DRs 012 and 106. I hope to fix these issues properly for 4.2 by moving information about whether an expression has the right syntax to be an lvalue, or is the result of * or [] operators, into the c_expr structure; the difference between the above cases is why this naturally involves two flags rather than one in that structure. It is however likely a simpler local fix could be found before then that examines the trees to distinguish the two cases. -- Summary: constraints on '&' not fully implemented Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jsm28 at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org OtherBugsDependingO 16620,16989 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22367