SIZEOF

jim at ISM780B.UUCP jim at ISM780B.UUCP
Mon Jan 21 15:28:45 AEST 1985


> K&R page 192 first paragraph:
>
>   "The compilers currently allow a pointer to be assigned to an integer,
>an integer to a pointer, and a pointer to a pointer of another type.
>THE ASSIGNMENT IS A PURE COPY OPERATION, WITH NO CONVERSION. This usage is
>nonportable, and may produce pointers which cause addressing exceptions
>when used. However, it is guaranteed that the assignment of the constant
>0 to a pointer will produce a null pointer distinguishable from a pointer
>to any object."

K&R is obsolete!  K&R is obsolete!  K&R is obsolete!  K&R is obsolete!
K&R is obsolete!  K&R is obsolete!  K&R is obsolete!  K&R is obsolete!
K&R is obsolete!  K&R is obsolete!  K&R is obsolete!  K&R is obsolete!

It is old, it is outdated, it is wrong.
Those compilers that allow structure assignment, separate name spaces
for structure members, and enums, that is, the compilers that implement
the real C language, the one described by the C reference manual that
AT&T distributes, and the one on which the ANSI standard is being based,
generate a warning when such assignments occur.  The C reference manual
does not allow them; values must be explicitly cast before being assigned.

>This says to me that the sizes must be the same. Changing the size is
>a conversion in my eye.

Have you seen an ophthalmologist lately?  :-)
Even given K&R, with its cavalier approach toward formal specification,
this is not a reasonable interpretation, because the above paragraph says
"integer", not "int", and a pointer can't be the same size as a char,
a short, an int, and a long all at the same time.

-- Jim Balter, INTERACTIVE Systems (ima!jim)



More information about the Comp.lang.c mailing list