1<html lang="en"> 2<head> 3<title>Disappointments - Using the GNU Compiler Collection (GCC)</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using the GNU Compiler Collection (GCC)"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Trouble.html#Trouble" title="Trouble"> 9<link rel="prev" href="Standard-Libraries.html#Standard-Libraries" title="Standard Libraries"> 10<link rel="next" href="C_002b_002b-Misunderstandings.html#C_002b_002b-Misunderstandings" title="C++ Misunderstandings"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 152010 Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Funding Free Software'', the Front-Cover 21Texts being (a) (see below), and with the Back-Cover Texts being (b) 22(see below). A copy of the license is included in the section entitled 23``GNU Free Documentation License''. 24 25(a) The FSF's Front-Cover Text is: 26 27 A GNU Manual 28 29(b) The FSF's Back-Cover Text is: 30 31 You have freedom to copy and modify this GNU Manual, like GNU 32 software. Copies published by the Free Software Foundation raise 33 funds for GNU development.--> 34<meta http-equiv="Content-Style-Type" content="text/css"> 35<style type="text/css"><!-- 36 pre.display { font-family:inherit } 37 pre.format { font-family:inherit } 38 pre.smalldisplay { font-family:inherit; font-size:smaller } 39 pre.smallformat { font-family:inherit; font-size:smaller } 40 pre.smallexample { font-size:smaller } 41 pre.smalllisp { font-size:smaller } 42 span.sc { font-variant:small-caps } 43 span.roman { font-family:serif; font-weight:normal; } 44 span.sansserif { font-family:sans-serif; font-weight:normal; } 45--></style> 46<link rel="stylesheet" type="text/css" href="../cs.css"> 47</head> 48<body> 49<div class="node"> 50<a name="Disappointments"></a> 51<p> 52Next: <a rel="next" accesskey="n" href="C_002b_002b-Misunderstandings.html#C_002b_002b-Misunderstandings">C++ Misunderstandings</a>, 53Previous: <a rel="previous" accesskey="p" href="Standard-Libraries.html#Standard-Libraries">Standard Libraries</a>, 54Up: <a rel="up" accesskey="u" href="Trouble.html#Trouble">Trouble</a> 55<hr> 56</div> 57 58<h3 class="section">11.7 Disappointments and Misunderstandings</h3> 59 60<p>These problems are perhaps regrettable, but we don't know any practical 61way around them. 62 63 <ul> 64<li>Certain local variables aren't recognized by debuggers when you compile 65with optimization. 66 67 <p>This occurs because sometimes GCC optimizes the variable out of 68existence. There is no way to tell the debugger how to compute the 69value such a variable “would have had”, and it is not clear that would 70be desirable anyway. So GCC simply does not mention the eliminated 71variable when it writes debugging information. 72 73 <p>You have to expect a certain amount of disagreement between the 74executable and your source code, when you use optimization. 75 76 <p><a name="index-conflicting-types-3322"></a><a name="index-scope-of-declaration-3323"></a><li>Users often think it is a bug when GCC reports an error for code 77like this: 78 79 <pre class="smallexample"> int foo (struct mumble *); 80 81 struct mumble { ... }; 82 83 int foo (struct mumble *x) 84 { ... } 85</pre> 86 <p>This code really is erroneous, because the scope of <code>struct 87mumble</code> in the prototype is limited to the argument list containing it. 88It does not refer to the <code>struct mumble</code> defined with file scope 89immediately below—they are two unrelated types with similar names in 90different scopes. 91 92 <p>But in the definition of <code>foo</code>, the file-scope type is used 93because that is available to be inherited. Thus, the definition and 94the prototype do not match, and you get an error. 95 96 <p>This behavior may seem silly, but it's what the ISO standard specifies. 97It is easy enough for you to make your code work by moving the 98definition of <code>struct mumble</code> above the prototype. It's not worth 99being incompatible with ISO C just to avoid an error for the example 100shown above. 101 102 <li>Accesses to bit-fields even in volatile objects works by accessing larger 103objects, such as a byte or a word. You cannot rely on what size of 104object is accessed in order to read or write the bit-field; it may even 105vary for a given bit-field according to the precise usage. 106 107 <p>If you care about controlling the amount of memory that is accessed, use 108volatile but do not use bit-fields. 109 110 <li>GCC comes with shell scripts to fix certain known problems in system 111header files. They install corrected copies of various header files in 112a special directory where only GCC will normally look for them. The 113scripts adapt to various systems by searching all the system header 114files for the problem cases that we know about. 115 116 <p>If new system header files are installed, nothing automatically arranges 117to update the corrected header files. They can be updated using the 118<samp><span class="command">mkheaders</span></samp> script installed in 119<samp><var>libexecdir</var><span class="file">/gcc/</span><var>target</var><span class="file">/</span><var>version</var><span class="file">/install-tools/</span></samp>. 120 121 <li><a name="index-floating-point-precision-3324"></a>On 68000 and x86 systems, for instance, you can get paradoxical results 122if you test the precise values of floating point numbers. For example, 123you can find that a floating point value which is not a NaN is not equal 124to itself. This results from the fact that the floating point registers 125hold a few more bits of precision than fit in a <code>double</code> in memory. 126Compiled code moves values between memory and floating point registers 127at its convenience, and moving them into memory truncates them. 128 129 <p><a name="index-ffloat_002dstore-3325"></a>You can partially avoid this problem by using the <samp><span class="option">-ffloat-store</span></samp> 130option (see <a href="Optimize-Options.html#Optimize-Options">Optimize Options</a>). 131 132 <li>On AIX and other platforms without weak symbol support, templates 133need to be instantiated explicitly and symbols for static members 134of templates will not be generated. 135 136 <li>On AIX, GCC scans object files and library archives for static 137constructors and destructors when linking an application before the 138linker prunes unreferenced symbols. This is necessary to prevent the 139AIX linker from mistakenly assuming that static constructor or 140destructor are unused and removing them before the scanning can occur. 141All static constructors and destructors found will be referenced even 142though the modules in which they occur may not be used by the program. 143This may lead to both increased executable size and unexpected symbol 144references. 145</ul> 146 147 </body></html> 148 149