inconsistency in C manual
Henry Spencer
henry at utzoo.UUCP
Sun Mar 11 15:24:05 AEST 1984
There is an inconsistency of a somewhat annoying nature between the
V7 C Reference Manual / appendix to K+R and the V7 (at least) cc:
Hear ye section 7.1 of the manual:
...A primary expression followed by a dot followed by an
identifier is an expression. *The first expression must be
an lvalue naming a structure or union*...
Consider the following:
struct foo { int bar; };
extern struct foo f();
g()
{
int x;
x = f().bar;
}
By the same section of the white book, a function call is *not* an
lvalue. Yet the V7 compiler (and probably most compilers) takes this
program fragment without complaint.
Clearly the compilers are doing the right thing; picking out one field
of a structure returned value is a reasonable thing to do. And clearly
the manual is out of date on this point, since structure returns were a
late addition to the language. But how does one fix the manual to permit
this particular usage? Any ideas? Do any of the more recent C manuals
shed any light on this? (We have the System V distribution but it's not
where I can get at it quickly.)
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,linus,decvax}!utzoo!henry
More information about the Comp.lang.c
mailing list