Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!dogie.macc.wisc.edu!gatech!hubcap!ncrcae!ncr-sd!hp-sdd!hp-pcd!hplsla!jima From: jima@hplsla.HP.COM (Jim Adcock) Newsgroups: comp.lang.c++ Subject: Re: operator functions and classes (was Re: Time to standardize "true" and "false") Message-ID: <6590293@hplsla.HP.COM> Date: 9 Oct 89 18:37:54 GMT References: Organization: HP Lake Stevens, WA Lines: 37 //here's another simple test for those who complain my previous test can //be evaluated by a compiler completely at compile time while still generating //bogus runtime evaluations. [Obviously, no amount of testing can "prove" a //real compiler works right. What I'm trying to do is convince any remaining //sceptics who still think there is a compiler that evaluates !!x to mean x //to find it for us! [I've yet to hear from *anyone* who actually has found //a compiler that generates bogus code for !!x. --Or maybe whoever wrote //such a compiler is too ashamed to admit it! :-]] #ifdef __cplusplus extern "C" { int printf(const char* const, ...); int rand(); // yes I *know* rand is weak -- its also widely available. void exit(int status); }; #endif main() { int i,j,k; for (i=0; i<1000; ++i) { j = ((unsigned char)(rand()))-128; k = (j!=0); if (k != (!!j)) { printf("failure on: %d\n",j); exit(1); } else { printf("success on: %d\n",j); } } }