`interesting' program

Shankar Unni shankar at hpclscu.HP.COM
Tue Jul 11 08:39:10 AEST 1989


> IMHO 2) is the winner! ISEHO 3) is right.
> 
> I say: zork() is a constant of type struct foo, so you cannot take its
> address and it isn't an lvalue.
> SE says: zork() is the name of a struct foo, so you CAN take its address.

You're right, the SE is wrong.

zork() is not exactly a "constant", but it is an expression of type struct
foo. However, it is *not* an lvalue so you cannot take its address.  Since
it is a structure expression, you can select a member (you do not have
to have an lvalue to do a member selection, even though many compilers
prevent you from selecting a member from a non-lvalue struct). Try this
expression on for size:

    struct foo func1(), func2();
    int i;
    
    (i ? func1() : func2()).mids;
----
Shankar Unni.
Hewlett-Packard California Language Lab.



More information about the Comp.lang.c mailing list