Disappointments.html 8.5 KB

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