Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ucbcad!ucbvax!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: comp.lang.c Subject: Clarifications on ANSI C nits Message-ID: <3725@hoptoad.uucp> Date: 24 Dec 87 02:06:49 GMT Organization: Nebula Consultants in San Francisco Lines: 71 While testing the GNU C compiler using the MetaWare C Validation Suite, I found a bunch of things that are not clearly marked in the Oct 86 copy of the C draft standard. I'm interested in clarification from the group and/or from the standards committee on these: * I've heard a rumor that in newer drafts, hex escape sequences inside strings are no longer limited to 3 characters, e.g. "abc\x00345" produces "abcE" since 'E' (0x45) is (char)0x00345. This strikes me as odd. * Is a "const void *" a void pointer? Is a "volatile void *"? Howabout a "const volatile void *"? Howabout a "void *const"? A "pointer to void" gets special treatment in a few places (e.g. in assignment) but it's not clear whether these are "pointers to void". (Howabout "volatile void *noalias const foo", just for fun?) * It appears from the text in section 3.5.3.3 that variable-argument-list functions can ONLY be defined in the foo(int c, float bar, ...) syntax, and not in the foo(c, bar, ...) int c; float bar; syntax. GCC implements it this way. However, this makes it impossible to support since no existing code uses the new declaration method. It also seems to be a silly inconsistency. * Though a union can now be initialized, you can only initialize one member, but you have to surround it with { } anyway. To correctly initialize the structure below, ALL the braces used are required: struct s{union {int x,y; int z;} u; int q;} s[2] = {{{1}, 2}, {{3}, 4}}; I would have expected: {1, 2, 3, 4}; to work, but the wording of the standard does not support it. Furthermore, the standard does not allow extra braces (e.g. around 2 and 4, or around the whole thing), so you have to get it exactly right. Is this what was intended? (These next two aren't from the validation suite.) * When calling a function, side effects caused by evaluating the arguments must be complete before the call takes place. What about side effects caused by evaluating the function name? Ron Light gave this example: typedef int (*Inst)(); /* machine instruction */ Inst *pc; /* program counter during execution */ execute(p) /* run the machine */ Inst *p; { for(pc = p;;) (*(*pc++))(); } If I reference "pc" from inside a function called from the forloop, is its value guaranteed to be incremented, to not be incremented, or not guaranteed? * Are null statements (extra semicolons) allowed between declarations? Between struct/union members' declarations? -- {pyramid,ptsfa,amdahl,sun,ihnp4}!hoptoad!gnu gnu@toad.com I forsee a day when there are two kinds of C compilers: standard ones and useful ones ... just like Pascal and Fortran. Are we making progress yet? -- ASC:GUTHERY%slb-test.csnet