[cfe-dev] Semantics for dereferencing incomplete types?
Neil Booth
neil at daikokuya.co.uk
Tue Jan 15 06:33:42 PST 2008
Eli Friedman wrote:-
> > Correct behaviour there depends on dialect:
> >
> > neil at duron:~/src/c$ ~/src/cfe/cfe /tmp/bug.c --c90
> > "/tmp/bug.c", line 4: error: expression must be an lvalue or a function
> > void* y = &*x;
> > ^
> > "/tmp/bug.c", line 4: warning: variable "y" declared but not used
> > void* y = &*x;
> > ^
> >
> > 1 error found compiling "/tmp/bug.c".
> > neil at duron:~/src/c$ ~/src/cfe/cfe /tmp/bug.c --c99
> > "/tmp/bug.c", line 4: warning: variable "y" declared but not used
> > void* y = &*x;
> > ^
>
> Right... it's actually a completely different case from the first two
> functions because void expressions aren't lvalues.
>
> Wow, the C standard is really confusing.
It's worse. qualified void is an lvalue, so qualifying the voids
in C90 should be accepted not rejected :) So for example (excuse
my posting more output from my FE) in the following c is bad but
d is OK:
$ ~/src/cfe/cfe /tmp/bug.c --c90
"/tmp/bug.c", line 1: error: expression must be an lvalue or a function
void f(void) { void *a; const void *b; void *c = &*a; const void *d =
&*b; }
^
"/tmp/bug.c", line 1: warning: variable "c" declared but not used
void f(void) { void *a; const void *b; void *c = &*a; const void *d =
&*b; }
^
"/tmp/bug.c", line 1: warning: variable "d" declared but not used
void f(void) { void *a; const void *b; void *c = &*a; const void *d =
&*b; }
^
1 error found compiling "/tmp/bug.c".
GCC doesn't get all this stuff right from what I remember; there
are outstanding PRs. It's not hard to get right though.
Neil.
More information about the cfe-dev
mailing list