"Invalid lvalue" when taking the address of an explicit struct?

Matthias Urlichs smurf@noris.de
Mon Mar 29 07:50:00 GMT 1999


Hi,

given the following program..:

struct foo { int bar; } ;
void baz(const struct foo *x) {}

main() {
    int y = 2;
	struct foo oof = ((struct foo){y});

    baz(&(struct foo){y});
    baz(&(struct foo){2});
    baz(&oof);
}   

... only the first call to baz() triggers an error
"invalid lvalue in unary `&'".

I wonder why -- it's no lvalue, it's the address of a struct; whether
the struct is built using varables or not should not make a lot of
difference to gcc..?

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
The seeds of repentance are sown in youth by pleasure, but the harvest
is reaped in age by plain.
                                -- Colton


More information about the Gcc mailing list