[5083] in Athena Bugs
still more about sendmail from comp.bugs.4bsd
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Jun 5 21:46:32 1990
Date: Tue, 5 Jun 90 21:46:20 -0400
From: Jonathan I. Kamens <jik@PIT-MANAGER.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
In-Reply-To: bugs[5071]
In article <1990Jun06.012731.18902@comp.vuw.ac.nz>,
Andy.Linton@comp.vuw.ac.nz (Andy Linton) writes:
|> In article <60685@lll-winken.LLNL.GOV>, casey@gauss.llnl.gov (Casey
|> Leedom) writes:
|> |>
|> |> No, the problem was because the test was:
|> |>
|> |> sizeof(foo) - int expression < 0
|> |>
|> |> Sizeof returns unsigned which gives us:
|> |>
|> |> unsigned expression - int expression < 0
|> |>
|> |> which type promoting turns into:
|> |>
|> |> unsigned expression < 0
|> |>
|> |> which can never be true. As far as I know ANSI C has not changed
anything
|> |> that would affect this.
|>
|> 'sizeof' used to return an 'int' (see page 126, The C Programming
|> Language, Kernighan and Ritchie, 1978) and that while Harbison and
|> Steele (C: A Reference Manual, First Edition, Page 154, 1984)
|> recommended "that the result of the 'sizeof' operator be either of type
|> 'unsigned int' or of type 'unsigned long'at the discretion of the
|> implementor" it wasn't standardised at that time.
|>
|> In Harbison and Steele, C: A Reference Manual, Second Edition, Page 273
|> they say in referring to Draft Proposed ANSI C that "the result of the
|> 'sizeof' operator may be of type 'unsigned int' or 'unsigned long'. The
|> type chosen by and implementation is defined as 'size_t' in the standard
|> header file 'stddef.h'." They also say on Page 299 that the draft
|> standard requires "the return type of 'strlen' to be 'size_t'".
|>
|> The point I was making was that because the type returned by 'sizeof'
|> and 'strlen' is now 'size_t' which is now *defined* to be 'unsigned int'
|> or 'unsigned long' the test fails for the reason Casey gives. Previously
|> the values returned by 'sizeof' and 'strlen' were implementation
|> dependent and the original test was written in a non-portable manner.
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
jik@Athena.MIT.EDU Allston, MA 02134
Office: 617-253-8495 Home: 617-782-0710