// filename:c2011-5-1-2-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 5.1.2.3 Program execution // 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 int main(void){ char c1, c2; /* ... */ c1 = c1 + c2; printf("%d %d ",c1, c2); float f1, f2; double d; /* ... */ f1 = f2 * d; printf("%f %f ", f1,f2); double d1, d2; float f; d1 = f = 3/4; d2 = (float) 3/4; printf("%f %f ", d1,d2); double x, y, z; /* ... */ x = (x * y) * z; // not equivalent tox *= y * z; z = (x - y) + y ; // not equivalent toz = x; z = x + x * y; // not equivalent toz = x * (1.0 + y); y = x / 5.0; // not equivalent toy = x * 0.2; printf("%f %f %f ",x,y,z); int a, b; /* ... */ a = a + 32760 + b + 5; printf("%d ",a); a = ((a + b) + 32765); printf("%d ",a); a = ((a + 32765) + b); printf("%d ",a); a = (a + (b + 32765)); printf("%d ",a); printf("\n5.1.2.3 Program execution\n"); } // 1. output LLVM 3.2 // 0 0 0.000000 0.000000 0.000000 0.750000 0.000000 0.000000 0.000000 138141694 276283387 414425080 552566773 // 5.1.2.3 Program execution // 2. output GCC 4.9 // 0 0 0.000000 644777966113331871744.000000 0.000000 0.750000 0.000000 0.000000 0.000000 32779 65544 98309 131074 // 5.1.2.3 Program execution