Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: comp.lang.c Subject: ! operator in constant expressions Message-ID: <3813@hoptoad.uucp> Date: 10 Jan 88 10:46:03 GMT Organization: Nebula Consultants in San Francisco Lines: 27 I just wrote an interesting test program for ! and haven't yet found a compiler that correctly implements the draft ANSI standard for it. Try it on yours, and let me know (if it works -- I already believe it will fail). If anyone can show me how this program is not fully conformant to the draft standard, I would also like to know. int install = !0; /* Gcc 1.16 said "initializer is not constant" */ /* Gcc 1.17 gets wrong answer! */ char foo = !1; int bar = !3.14156; /* SunOS 3.3 cc said "Illegal initialization" */ int pno = ! &bar; /* Gcc 1.17 said "initializer for static variable uses complex arithmetic" */ int pyes = !(char *)0; main() { if (install && !foo && !bar && pyes && !pno) printf("Test passed\n"); else printf("FAILED, install=%d, foo=%d, bar=%d, pno=%d, pyes=%d\n", install, foo, bar, pno, pyes); } -- {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