// filename:c2011-6-8-3-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf // C2011 6.8.3 Expression and null statements // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.xx, 2013 // compile errors and/or wornings: // 1 (c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn) // Target: x86_64-apple-darwin11.4.2 //Thread model: posix // (c) LLVM 2003-2009 University of Illinois at Urbana-Champaign. // 2 gcc-4.9 (GCC) 4.9.0 20131229 (experimental) // Copyright (C) 2013 Free Software Foundation, Inc. #include // Example 1 int p(int); /* ... */ int p(int i){ return printf("i=%d ",i),i;} int main(void) { (void)p(0); // Example 2 char *s; /* ... */printf("s=%s ",s); while (*s++ != '\0') printf("s=%d ",(int)*s); // Example 3 int loop1, loop2, want_out; printf("loop1=%d ",loop1);printf("loop2=%d ",loop2);printf("want_out=%d ",want_out); while (loop1) { /* ... */ printf("loop1=%d ",loop1); while (loop2) { /* ... */ printf("loop2=%d ",loop2); if (want_out) printf("want_out=%d ",want_out);goto end_loop1; /* ... */ } /* ... */ end_loop1: ; } return printf("\n 6.8.3 Expression and null statements %d %d\n",p(1),*s); } // 1. LLVM3.2 output may be //i=0 s= loop1=0 loop2=0 want_out=0 i=1 // 6.8.3 Expression and null statements 1 0 // 2. GCC4.9 output // Segmentation fault: 11