Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #6136

7.1.4p2 vs. Annex J

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.std.c
Subject 7.1.4p2 vs. Annex J
Date 2020-08-03 20:42 -0700
Organization None to speak of
Message-ID <87bljr84ay.fsf@nosuchdomain.example.com> (permalink)

Show all headers | View raw


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 */

Back to comp.std.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

7.1.4p2 vs. Annex J Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-03 20:42 -0700
  Re: 7.1.4p2 vs. Annex J Ike Naar <ike@otaku.sdf.org> - 2020-08-04 05:26 +0000
  Re: 7.1.4p2 vs. Annex J Philipp Klaus Krause <pkk@spth.de> - 2020-08-04 10:53 +0200
    Re: 7.1.4p2 vs. Annex J Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-04 07:29 -0700
  Re: 7.1.4p2 vs. Annex J Andy Walker <anw@cuboid.co.uk> - 2020-08-05 10:47 +0100

csiph-web