You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
8.4 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2018 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below). A copy of the license is included in the section entitled
"GNU Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development. -->
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Disappointments (Using the GNU Compiler Collection (GCC))</title>
<meta name="description" content="Disappointments (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Disappointments (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Trouble.html#Trouble" rel="up" title="Trouble">
<link href="C_002b_002b-Misunderstandings.html#C_002b_002b-Misunderstandings" rel="next" title="C++ Misunderstandings">
<link href="Standard-Libraries.html#Standard-Libraries" rel="prev" title="Standard Libraries">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Disappointments"></a>
<div class="header">
<p>
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>
</div>
<hr>
<a name="Disappointments-and-Misunderstandings"></a>
<h3 class="section">13.6 Disappointments and Misunderstandings</h3>
<p>These problems are perhaps regrettable, but we don&rsquo;t know any practical
way around them.
</p>
<ul>
<li> Certain local variables aren&rsquo;t recognized by debuggers when you compile
with optimization.
<p>This occurs because sometimes GCC optimizes the variable out of
existence. There is no way to tell the debugger how to compute the
value such a variable &ldquo;would have had&rdquo;, and it is not clear that would
be desirable anyway. So GCC simply does not mention the eliminated
variable when it writes debugging information.
</p>
<p>You have to expect a certain amount of disagreement between the
executable and your source code, when you use optimization.
</p>
</li><li> <a name="index-conflicting-types"></a>
<a name="index-scope-of-declaration"></a>
Users often think it is a bug when GCC reports an error for code
like this:
<div class="smallexample">
<pre class="smallexample">int foo (struct mumble *);
struct mumble { &hellip; };
int foo (struct mumble *x)
{ &hellip; }
</pre></div>
<p>This code really is erroneous, because the scope of <code>struct
mumble</code> in the prototype is limited to the argument list containing it.
It does not refer to the <code>struct mumble</code> defined with file scope
immediately below&mdash;they are two unrelated types with similar names in
different scopes.
</p>
<p>But in the definition of <code>foo</code>, the file-scope type is used
because that is available to be inherited. Thus, the definition and
the prototype do not match, and you get an error.
</p>
<p>This behavior may seem silly, but it&rsquo;s what the ISO standard specifies.
It is easy enough for you to make your code work by moving the
definition of <code>struct mumble</code> above the prototype. It&rsquo;s not worth
being incompatible with ISO C just to avoid an error for the example
shown above.
</p>
</li><li> Accesses to bit-fields even in volatile objects works by accessing larger
objects, such as a byte or a word. You cannot rely on what size of
object is accessed in order to read or write the bit-field; it may even
vary for a given bit-field according to the precise usage.
<p>If you care about controlling the amount of memory that is accessed, use
volatile but do not use bit-fields.
</p>
</li><li> GCC comes with shell scripts to fix certain known problems in system
header files. They install corrected copies of various header files in
a special directory where only GCC will normally look for them. The
scripts adapt to various systems by searching all the system header
files for the problem cases that we know about.
<p>If new system header files are installed, nothing automatically arranges
to update the corrected header files. They can be updated using the
<code>mkheaders</code> script installed in
<samp><var>libexecdir</var>/gcc/<var>target</var>/<var>version</var>/install-tools/</samp>.
</p>
</li><li> <a name="index-floating-point-precision"></a>
On 68000 and x86 systems, for instance, you can get paradoxical results
if you test the precise values of floating point numbers. For example,
you can find that a floating point value which is not a NaN is not equal
to itself. This results from the fact that the floating point registers
hold a few more bits of precision than fit in a <code>double</code> in memory.
Compiled code moves values between memory and floating point registers
at its convenience, and moving them into memory truncates them.
<a name="index-ffloat_002dstore-1"></a>
<p>You can partially avoid this problem by using the <samp>-ffloat-store</samp>
option (see <a href="Optimize-Options.html#Optimize-Options">Optimize Options</a>).
</p>
</li><li> On AIX and other platforms without weak symbol support, templates
need to be instantiated explicitly and symbols for static members
of templates will not be generated.
</li><li> On AIX, GCC scans object files and library archives for static
constructors and destructors when linking an application before the
linker prunes unreferenced symbols. This is necessary to prevent the
AIX linker from mistakenly assuming that static constructor or
destructor are unused and removing them before the scanning can occur.
All static constructors and destructors found will be referenced even
though the modules in which they occur may not be used by the program.
This may lead to both increased executable size and unexpected symbol
references.
</li></ul>
<hr>
<div class="header">
<p>
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>
</div>
</body>
</html>