Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: isspace() executes without ctype header? Date: Wed, 14 Jun 2017 12:03:44 -0700 Organization: None to speak of Lines: 43 Message-ID: References: <65b55827-2e50-474e-8b47-a5d70747b53b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="96bbf95725af2559ab0735ee54475e20"; logging-data="3357"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yYmVigaoIRfdlwViksKhw" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:6Hbq6tnEmXsH1lyoDCGODu5c2b8= sha1:qFEPCOCqxkm7/DwkhK8vXu+6UGw= Xref: csiph.com comp.lang.c:112214 supercat@casperkitty.com writes: > On Wednesday, June 14, 2017 at 11:54:20 AM UTC-5, Bart wrote: >> In the second example, the argument type is char*, the assumed parameter >> type is int. Why doesn't it complain about pointer to int conversion? It >> will do so when the int parameter is properly declared. > > The assumed return type is "int". The assumed parameter type is whatever > would match an argument that has been subjected to default promotions. > When C was first designed, there were three categories of arguments, and > thus three types of parameters: > > A pointer of some kind (pass as the bulkiest pointer type) > A floating-point number of some kind (pass as the bulkiest FP type) > An integer of some kind (pass as the bulkiest integer type) I don't recall there being any concept of the "bulkiest pointer type". Pointer types are distinct, and an int* argument would be passed as int* even if char* is bigger. (Note that there was no void*.) If you passed an int* argument to a function expecting a char*, I think you'd have what C currently calls undefined behavior, particularly if they have different representations. Both cman74.pdf and cman.pdf (from 1975, I think) says that char arguments are promoted to int, and float arguments to double. (char, int, float, and double were the only numeric types.) No other conversions are specified. > The principle that the type used to pass an argument to a parameter of > unknown type should depend merely on the category, rather than its exact > type, is a good one, but was not retained when C added more types. It > works fine for the C74 types, though. Yes, when long and long double were added, the unstated "bulkiest type" rule was not extended to include them. But I'm not convinced there ever was such a rule, even implicitly, since it never applied to pointers. (Or, later, to structs and unions.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"