This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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