// filename:c2011-F-8-5-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // C2011 F.8.5 Initialization // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.29, 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. // /usr/local/Cellar/gcc49/4.9-20131229/bin/gcc-4.9 -std=c11 c2011-F-8-5-ex.c #include #include // Example #include #pragma STDC FENV_ACCESS ON void f(void) { float u[] = { 1.1e75 }; // raises exceptions static float v = 1.1e75; // does not raise exceptions float w = 1.1e75; // raises exceptions double x = 1.1e75; // may raise exceptions float y = 1.1e75f; // may raise exceptions long double z = 1.1e75; // does not raise exceptions /* ... */ printf("%f %f %f %lf %f %Lf \n",*u, v, w, x, y, z); } int main(void) { f(); // note 367) double_t x = 1.1e75; printf("%lf\n",x); return printf("F.8.5 Initializationf\n"); } // warning1(LLVM3.2) may be // c2011-F-8-5-ex.c:14:14: warning: pragma STDC FENV_ACCESS ON is not supported, ignoring pragma [-Wunknown-pragmas] // #pragma STDC FENV_ACCESS ON // ^ // c2011-F-8-5-ex.c:21:11: warning: magnitude of floating-point constant too large for type 'float'; maximum is 3.4028235E+38 [-Wliteral-range] // float y = 1.1e75f; // may raise exceptions // ^ // 2 warnings generated. // warning(GCC4.9) // worning2(GCC4.9) may be // c2011-F-8-5-ex.c:23:1: warning: floating constant exceeds range of 'float' [-Woverflow] // float y = 1.1e75f; // may raise exceptions // ^ // output may be (same LLVM3.2 and GCC4.9) // inf inf inf 1100000000000000059800838166790967925781366616571142396681673017752771624960.000000 inf 1100000000000000059800838166790967925781366616571142396681673017752771624960.000000 // 1100000000000000059800838166790967925781366616571142396681673017752771624960.000000 // F.8.5 Initializationf