Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Untyped Variables Date: Sat, 08 Aug 2015 12:09:06 -0700 Organization: None to speak of Lines: 51 Message-ID: References: <83a58dd3-53a6-422a-8502-4fef870baf70@googlegroups.com> <55C61BBF.8090302@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="12199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Z1Y/8HHNXz6y0Y1rLYlCC" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:g5EPF9WVjL6hLUlwXxcsOZjeAKA= sha1:cq8KbujteU3PXvk3BHBcrj2GUB8= Xref: csiph.com comp.lang.c:67007 James Kuyper writes: [...] > c) Any use of a previously undeclared identifier was treated, if > possible, as if it were the name of a function with external linkage > returning 'int'. If arguments were given for the function, it was > treated as though the corresponding declaration had parameters of the > same type. > > Thus > auto a; > const b; > c; > > Were equivalent to > auto int a; > const int b; > int c(); > c; // expression statement consisting of the name of a > // function, implicitly converted to a pointer to the > // function type. Useless, but legal. No, the last one is an undeclared identifier error; the rule applies only to function *calls*. The C90 rule for function calls is/was: If the expression that precedes the parenthesized argument list in a function call consists solely of an identifier. and if no declaration is visible for this identifier, the identifier is implicitly declared exactly as if, in the innermost block containing the function call, the declaration extern int identifier () ; appeared. So this: c(); creates an implicit function declaration: int c(); And if such a call has arguments, any arguments narrower than int or double are promoted -- and if the resulting argument types are inconsistent with the types in the actual function *definition*, the behavior is undefined. [...] -- 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"