Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.std.c Subject: 7.1.4p2 vs. Annex J Date: Mon, 03 Aug 2020 20:42:45 -0700 Organization: None to speak of Lines: 35 Message-ID: <87bljr84ay.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="8e1a0ffdbf8d1772d4a70bcdb1fd17b6"; logging-data="7833"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mndXUsm23G4Gb/OKMMtXm" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:nNogI0+WOiev8OMohRo7OcuhZ8Y= sha1:ePcpSo4iLlOWCcK65Zi3bqM5HZA= Xref: csiph.com comp.std.c:6136 Joe Zbiciak and I discovered this in a discussion on Quora. N1570 7.1.4p2 says: Provided that a library function can be declared without reference to any type defined in a header, it is also permissible to declare the function and use it without including its associated header. which means that this is a valid "Hello, world" program: int puts(const char *s); int main(void) { puts("Hello, world"); } But J.2 (which is non-normative) says that the behavior is undefined if: A function, object, type, or macro that is specified as being declared or defined by some standard header is used before any header that declares or defines it is included (7.1.2). which the above program violates. Is the intent behind that paragraph in J.2 something other than what it seems to be? (Or am I misreading it?) Or is it just wrong? Other than declaring a function, as permitted by 7.1.4p2, how would a program even violate that paragraph in J.2 without also violating a constraint? -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */