This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Update known bugs list


Hi,
[this is a repeat, the mailer marked the attachments as html]
here's an updated bugs.html which documents issues I am aware of with
g++. I've included both patch and new file, so it's easier for you to
check.

I've changed 2.95 -> 3.0 in the preamble etc, and updated the C++
section. There are a couple of issues in the 'General' section, which
might well be fixed now:

* GCC 2.95.2 does not build on GNU/Linux systems using glibc 2.2,
such as Red Hat 7.0.  A <a href="install/glibc-2.2.patch">patch</a> is
available.  This will be fixed in GCC 2.95.3 and GCC 3.0.</li>

* GCC 2.95.2 crashes when compiling <code>mbx.c</code> from the PINE
4.30 or IMAP2000 distribution on Sparc systems running Solaris.</li>

Are these resolved?

Are there things I've missed?

Shall I install this?

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk

Index: htdocs/bugs.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/bugs.html,v
retrieving revision 1.28
diff -c -3 -p -r1.28 bugs.html
*** bugs.html	2001/03/07 12:43:42	1.28
--- bugs.html	2001/06/15 10:06:35
***************
*** 11,17 ****
  
  <p><a href="#report">Reporting Bugs</a>
   | <a href="#manage">Managing Bugs (GNATS and the test-suite)</a>
!  | <a href="#known">Frequently Reported Bugs in GCC 2.95</a>
  </p>
  
  <h1><a name="report">Reporting Bugs</a></h1>
--- 11,17 ----
  
  <p><a href="#report">Reporting Bugs</a>
   | <a href="#manage">Managing Bugs (GNATS and the test-suite)</a>
!  | <a href="#known">Frequently Reported Bugs in GCC 3.0</a>
  </p>
  
  <h1><a name="report">Reporting Bugs</a></h1>
*************** well-known bugs</a> and, <strong>if poss
*** 24,30 ****
  development snapshot
  or <a href="http://www.codesourcery.com/gcc-compile.shtml";>CodeSourcery's
  Online Test Compilation</a></strong>.  If you want to report a
! bug with egcs 1.x or versions of GCC before 2.95 we strongly recommend
  upgrading to the current release first.</p>
  
  <p>Before reporting that GCC compiles your code incorrectly, please
--- 24,30 ----
  development snapshot
  or <a href="http://www.codesourcery.com/gcc-compile.shtml";>CodeSourcery's
  Online Test Compilation</a></strong>.  If you want to report a
! bug with egcs 1.x or versions of GCC before 3.0 we strongly recommend
  upgrading to the current release first.</p>
  
  <p>Before reporting that GCC compiles your code incorrectly, please
*************** requested in this summary.</p>
*** 43,49 ****
  Please include in your bug report <b>all</b> of the following items:
  
  <ul>
!   <li>The GCC version (not just 2.xx; run <code>gcc -v</code>)</li>
    <li>The system type (the dir name after <code>gcc-lib</code> in the
    output of <code>gcc -v</code></li>
    <li>The complete command line that triggers the bug</li>
--- 43,49 ----
  Please include in your bug report <b>all</b> of the following items:
  
  <ul>
!   <li>The GCC version (not just 3.xx; run <code>gcc -v</code>)</li>
    <li>The system type (the dir name after <code>gcc-lib</code> in the
    output of <code>gcc -v</code></li>
    <li>The complete command line that triggers the bug</li>
*************** contributors.</p>
*** 200,206 ****
  </ol>
  
  
! <h1><a name="known">Frequently Reported Bugs in GCC 2.95</a></h1>
  
  <h2>General</h2>
  
--- 200,206 ----
  </ol>
  
  
! <h1><a name="known">Frequently Reported Bugs in GCC 3.0</a></h1>
  
  <h2>General</h2>
  
*************** Causes of Trouble with GNU Fortran"</a> 
*** 226,238 ****
  
  <h2>C++</h2>
  
! <p>This is the list of bugs in g++ (aka GNU C++) that are reported very often,
! but not yet
! fixed. While it is certainly better to fix bugs instead of documenting
! them, this document might save people the effort of writing a bug
! report when the bug is already well-known.
! <a href="#report">How to report bugs</a> tells you how to report a
! bug.
  
  <p>There are many reasons why reported bugs don't get fixed. It might
  be difficult to fix, or fixing it might break compatibility. Often,
--- 226,237 ----
  
  <h2>C++</h2>
  
! <p>This is the list of bugs (and non-bugs) in g++ (aka GNU C++) that
! are reported very often, but not yet fixed. While it is certainly
! better to fix bugs instead of documenting them, this document might
! save people the effort of writing a bug report when the bug is already
! well-known.  <a href="#report">How to report bugs</a> tells you how to
! report a bug.
  
  <p>There are many reasons why reported bugs don't get fixed. It might
  be difficult to fix, or fixing it might break compatibility. Often,
*************** C++. This means that code which might ha
*** 245,337 ****
  version, is now rejected. You should update your code to be C++.
  
  <p>You should try to use the latest stable release of the GNU C++
! compiler. This is currently 2.95. Many commonly reported bugs in earlier
  releases are fixed in that version.
  
! <h3><a name="access"></a>G++ allows to access private types</h3>
! GCC 2.95 incorrectly accepts code like
! <pre>
! struct X{
!  private:
!    struct Y{};
! };
  
! X::Y z;
! </pre>
  
! <p>Since <CODE>Y</CODE> is a private member of <CODE>X</CODE>, the
! definition of <CODE>z</CODE> should be rejected, but isn't. This
! applies to structs, classes and types in general; for other members of
! classes (functions and data), access control is implemented.</p>
  
! <p>In the development branch of GCC, this bug was fixed on Feb 7, 2000.
! The fix will appear in the next major release of GCC (after 2.95).</p>
  
! <h3><a name="export"></a>export not implemented</h3>
  
! As of GCC 2.95, the <CODE>export</CODE> keyword is not implemented. 
! This feature, when implemented, will permit moving
! definitions of templates out of header files; exported
! templates can be instantiated without a visible definition.
  
! <h3><a name="using"></a>Using declarations in classes do not work</h3>
  
! The Annotated Reference Manual (ARM) defines an access declaration for
! cases like
  
! <pre>
! struct X{
!  protected:
!    int i;
! };
  
! class Y: private X{
!   public:
!     X::i;
! };
  
! void f()
! {
!   Y y;
!   y.i=4;
! }
! </pre>
! Even though <CODE>X::i</CODE> is protected, it is redeclared public in
! <CODE>Y</CODE>.
  
! <p>Standard C++ extends this notion and aligns it with <CODE>using</CODE>
! declarations available in namespaces. In Standard C++, the following
! code is also valid:
! <pre>
! struct X{
!  protected:
!    int i(bool);
! };
  
! class Y: private X{
!   public:
!     int i(int);
!     using X::i;
! };
  
! void f()
! {
!   Y y;
!   y.i(true);
! }
! </pre>
  
! A <CODE>using</CODE> declaration not only redeclares access, it also permits
! merging functions from the base class into the derived class, which is
! convenient for overloading. In Standard C++, the ARM-style notation is
! equivalent to <CODE>using</CODE> declarations.
  
! <p>GCC 2.95 rejects this code. It treats <CODE>using</CODE> declarations in
! the same way as ARM-style access declarations.
  
  <h3><a name="parsing"></a>Parse errors for "simple" code</h3> 
  
! Up to and including GCC 2.95, the compiler will give "parse error" for
  seemingly simple code, such as
  
  <pre>
--- 244,374 ----
  version, is now rejected. You should update your code to be C++.
  
  <p>You should try to use the latest stable release of the GNU C++
! compiler. This is currently 3.0. Many commonly reported bugs in earlier
  releases are fixed in that version.
  
! <h3>Common problems updating from g++ 2.95 to g++ 3.0</h3>
  
! <p>g++ 3.0 conforms much closer to the ISO C++ standard (available at
! <a href="http://www.ncits.org/cplusplus.htm";>http://www.ncits.org/cplusplus.htm</a>).
! We have also implemented some of the core and library defect reports (available at
! <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html";>http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html</a>
! &amp; 
! <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html";>http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html</a> respectively).
  
! <ul>
  
! <li>The ABI has changed. This means that both class layout and name
! mangling is different. You <em>must</em> recompile all c++ libraries (if
! you don't you will get link errors).
! 
! <li>The standard library is much more conformant, and uses the
! <code>std::</code> namespace.
! 
! <li><code>std::</code> is now a real namespace, not an alias for
! <code>::</code>.
! 
! <li>The standard header files for the c library don't end with
! <code>.h</code>, but begin with <code>c</code> (i.e.
! <code>&lt;ctypes&gt;</code> rather than <code>&lt;types.h&gt;</code>).
! The <code>.h</code> names are still available, but are deprecated.
! 
! <li><code>&lt;strstream&gt;</code> is deprecated, use
! <code>&lt;stringstream&gt;</code> instead.
! 
! <li><code>streambuf::seekoff</code> &amp;
! <code>streambuf::seekpos</code> are private, instead use
! <code>streambuf::pubseekoff</code> &amp;
! <code>streambuf::pubseekpos</code> respectively.
! 
! <li>If <code>std::operator (std::ostream &amp;, long long)</code>
! doesn't exist, you need to recompile libstdc++ with
! <code>--enable-long-long</code>.
  
! </ul>
  
! This means you may get lots of errors about things like
! <code>strcmp</code> not being found. You've most likely forgotton to
! tell the compiler to look in the <code>std::</code> namespace. There are
! several ways to do this,
  
! <ul>
  
! <li>Say, <code>std::strcmp</code> at the call. This is the most explicit
! way of saying what you mean.
  
! <li>Say, <code>using std::strcmp;</code> somewhere before the call. You
! will need to do this for each function or type you wish to use from the
! standard library.
! 
! <li>Say, <code>using namespace std;</code> somewhere before the call.
! This is the quick-but-dirty fix. This brings the <em>whole</em> of the
! <code>std::</code> namespace into scope. <em>Never</em> do this in a
! header file, as you will be forcing users of your header file to do the
! same.
  
! </ul>
  
! <h3>Non-bugs</h3>
! Here are some features that have been reported as bugs, but are not.
  
! <dl>
  
! <dt>Nested classes can access private types of the containing class.
! <dd>G++ now implements type access control on member types. Defect
! report 45 clarifies that nested classes are members of the class they
! are nested in, and so are granted access to private members of that class.
! 
! <dt>Classes in exception specifiers must be complete types.
! <dd>[15.4]/1 tells you that you cannot have an incomplete type, or
! pointer to incomplete (other than <code><it>cv</it> void *</code>) in an
! exception specification.
  
! <dt>G++ emits two copies of constructors and destructors.
! <dd>In general there are <em>three</em> types of constructor (and destructor).
! <ol>
! <li>The complete object constructor/destructor.
! <li>The base object constructor/destructor.
! <li>The allocating destructor/deallocating destructor.
! </ol>
! The first two are different, when virtual base classes are involved.
! In some cases we can do better, and this is logged in GNATS.
  
! <dt>Exceptions don't work in multithreaded applications
! <dd>You need to rebuild g++ and libstdc++ with --enable-threads.
! Remember, c++ exceptions are not like hardware interrupts. You cannot
! throw an exception in one thread and catch it in another. You cannot
! throw an exception from a signal handler, and catch it in the main
! thread.
! 
! <dt>Global destructors are not run in the correct order
! <dd>Global destructors should be run in the reverse order of their
! constructors <em>completing</em>. In most cases this is the same as the
! reverse order of constructors <em>starting</em>, but sometimes it is
! different, and that is important. You need to compile and link your
! programs with <code>--use-cxa-atexit</code>. We have not turned this
! switch on by default, as it requires a <code>cxa</code> aware runtime
! library (<code>libc</code>, <code>glibc</code>, or equivalent).
! 
! </dl>
! 
! <h3>Missing features</h3>
! We know some things are missing from g++.
! 
! <dl>
! 
! <dt><code>export</code> is not implemented.
! <dd>The keyword will be parsed correctly, but has no effect.
! 
! <dt>Two stage lookup in templates is not implemented.
! <dd>[14.6] specifies how names are looked up inside a template. G++ does
! not do this correctly, but for most templates this will not be noticeable.
  
! <dt>
  
  <h3><a name="parsing"></a>Parse errors for "simple" code</h3> 
  
! Up to and including GCC 3.0, the compiler will give "parse error" for
  seemingly simple code, such as
  
  <pre>
*************** A B::f1(bool b)
*** 385,391 ****
    return a;
  }
  </pre>
! The problem is that the compiler interprets <CODE>A()</CODE> as a
  function (taking no arguments, returning <CODE>A</CODE>), and
  <CODE>(A()</CODE>) as a cast - with a missing expression, hence the
  parse error. The work-around is to omit the parentheses:
--- 422,428 ----
    return a;
  }
  </pre>
! <p>The problem is that the compiler interprets <CODE>A()</CODE> as a
  function (taking no arguments, returning <CODE>A</CODE>), and
  <CODE>(A()</CODE>) as a cast - with a missing expression, hence the
  parse error. The work-around is to omit the parentheses:
*************** parse error. The work-around is to omit 
*** 393,430 ****
    if (b)
      return A(); 
  </pre>
! This problem occurs in a number of variants; in <CODE>throw</CODE>
  statements, people also frequently put the object in parentheses. The
  exact error also somewhat varies with the compiler version. The
  work-arounds proposed do not change the semantics of the program at
  all; they make them perhaps less readable.
  
! <h3><a name="library"></a>C++ Library not compliant</h3>
! In Standard C++, the programmer can use a considerable run-time
! library, including the STL (Standard Template Library), iostreams
! for single-byte and wide characters, localization features, and
! others.
! 
! <p>Many of the standard library features are not implemented in GCC
! 2.95. Others, such as iostreams, are supported, but not in a
! compliant way (e.g. <CODE>ostream</CODE> is not
! <CODE>basic_ostream&lt;char&gt;</CODE>, and not
! declared in <CODE>std::</CODE>).
! 
! <p>SGI's implementation of the STL is included, but it is in the
! global namespace, not in <CODE>std::</CODE>.
! 
! <p>Work is underway to complete a <a href="libstdc++/">new C++
! library</a> which will provide all the functionality in a compliant
! way.
! 
! <h3><a name="exception"></a>Exception specifiers on function pointers</h3>
! <p>Although allowed by the standard, GCC 2.95 will report an
! 'invalid exception specifications' error if you
! declare a function pointer with an exception specification.
! <pre>
! void (*fptr)() throw();
! </pre>
  
  </body>
  </html>
--- 430,445 ----
    if (b)
      return A(); 
  </pre>
! <p>This problem occurs in a number of variants; in <CODE>throw</CODE>
  statements, people also frequently put the object in parentheses. The
  exact error also somewhat varies with the compiler version. The
  work-arounds proposed do not change the semantics of the program at
  all; they make them perhaps less readable.
  
! <h3>Optimization at <code>-O3</code> takes a very long time</h3>
! <p>At <code>-O3</code>, all functions are candidates for inlining. The
! heuristic used has some deficiencies which show up when allowed such
! freedom. This is g++ specific, as it has an earlier inliner than gcc.
  
  </body>
  </html>
<html>

<head>
<title>GCC Bugs</title>
</head>

<body>

<p>The latest version of this document is always available at
<a href="http://gcc.gnu.org/bugs.html";>http://gcc.gnu.org/bugs.html</a>.

<p><a href="#report">Reporting Bugs</a>
 | <a href="#manage">Managing Bugs (GNATS and the test-suite)</a>
 | <a href="#known">Frequently Reported Bugs in GCC 3.0</a>
</p>

<h1><a name="report">Reporting Bugs</a></h1>

<p>Our preferred way of receiving bugs is via our <a href="gnats.html">GNATS
bug reporting system</a>.</p>

<p>Before you report a bug, please check the <a href="#known">list of
well-known bugs</a> and, <strong>if possible in any way, try a current
development snapshot
or <a href="http://www.codesourcery.com/gcc-compile.shtml";>CodeSourcery's
Online Test Compilation</a></strong>.  If you want to report a
bug with egcs 1.x or versions of GCC before 3.0 we strongly recommend
upgrading to the current release first.</p>

<p>Before reporting that GCC compiles your code incorrectly, please
compile it with <code>gcc -Wall</code> and see whether this shows
anything wrong with your code that could be the cause instead of a bug
in GCC.</p>

<h2>Summarized bug reporting instructions</h2>

<p>After this summary, you'll find detailed bug reporting
instructions, that explain how to obtain some of the information
requested in this summary.</p>

<h3>What we need</h3>

Please include in your bug report <b>all</b> of the following items:

<ul>
  <li>The GCC version (not just 3.xx; run <code>gcc -v</code>)</li>
  <li>The system type (the dir name after <code>gcc-lib</code> in the
  output of <code>gcc -v</code></li>
  <li>The complete command line that triggers the bug</li>
  <li>The compiler output (error messages, warnings, etc)</li>
  <li>The <b>preprocessed</b> file (<t>*.i*</t>) that triggers the
  bug, generated by adding <code>-save-temps</code> to the complete
  compilation command (see below)</li>
  <li>The options given when GCC was configured/built</li>
</ul>

<h3>What we DON'T want</h3>

<ul>
  <li>A source file that <tt>#include</tt>s header files that are left
  out of the bug report (see above)</li>

  <li>That source file <b>and</b> a collection of header files (don't
  waste your time; the preprocessor will collect them for you! :-)

  <li>An attached archive (tar, zip, shar, whatever) containing all
  (or some :-) of the above, so that we can tell what the bug report
  is about without having to unarchive it</li>

  <li>A code snippet that won't cause the compiler to produce the
  exact output mentioned in the bug report (e.g., a snippet with just
  a few lines around the one that <b>apparently</b> triggers the bug,
  with some pieces replaced with ellipses or comments for extra
  obfuscation :-)</li>

  <li>The location (URL) of the package that failed to build (we won't
  download it, anyway, since you've already given us what we need to
  duplicate the bug, haven't you? :-)</li>

  <li>An error that occurs only some of the times a certain file is
  compiled, such that retrying a sufficient number of times results in
  a successful compilation; this is a symptom of a hardware problem,
  not of a compiler bug (sorry)</li>

  <li>E-mail messages that complement previous, incomplete bug
  reports; post a new, self-contained, full bug report instead, if
  possible as a follow-up (or reply) to the original bug report</li>

  <li>Assembly files (<t>*.s</t>) produced by the compiler, or any
  binary files, such as object files, executables or core files</li>

  <li>Duplicate bug reports, or reports of bugs already fixed in the
  development tree, especially those that have already been reported
  as fixed last week :-)</li>

  <li>Bugs in the assembler, the linker or the C library.  These are
  separate projects, with separate mailing lists and different bug
  reporting procedures</li>

  <li>Bugs in releases or snapshots of GCC not issued by the GNU
  Project.  Report them to whoever provided you with the release</li>

  <li>Questions about the correctness or the expected behavior of
  certain constructs that are not GCC extensions.  Ask them in forums
  dedicated to the discussion of the programming language</li>
</ul>

<h3>Where to post it</h3>

<p>Please submit your bug report directly to our
<a href="gnats.html">GNATS</a> bug database. If this is not possible,
please mail all information to
<href="mailto:gcc-bugs@gcc.gnu.org";>gcc-bugs@gcc.gnu.org</a>.


<h2>Detailed bug reporting instructions</h2>

<p>In general, all the information we need can be obtained by
collecting the command line below, as well as its output and the
preprocessed file it generates.</p>

<p><tt>gcc -v -save-temps <i>all-your-options source-file</i></tt></p>

<p>Typically the preprocessed file (extension <code>.i</code> for C or
<code>.ii</code> for C++) will be large, so please compress the
resulting file with one of the popular compression programs such as
<tt>bzip2</tt>, <tt>gzip</tt>, <tt>zip</tt> or <tt>compress</tt> (in
decreasing order of preference).  Use maximum compression
(<code>-9</code>) if available.  <b>Please</b> include the compressed
preprocessor output in your bug report, even if the source code is
freely available elsewhere; it makes the job of our volunteer testers
much easier.</p>

<p>The <b>only</b> excuses to not send us the preprocessed sources are
(i) if you've found a bug in the preprocessor, or (ii) if you've
reduced the testcase to a small file that doesn't include <b>any</b>
other file.  If you can't post the preprocessed sources because
they're proprietary code, then try to create a small file that
triggers the same problem.</p>

<p>Since we're supposed to be able to re-create the assembly output
(extension <code>.s</code>), you usually should <b>not</b> include
it in the bug report, although you may want to post parts of it to
point out assembly code you consider to be wrong.</p>

<p>Whether to use MIME attachments or <code>uuencode</code> is up to
you.  In any case, make sure the compiler command line, version and
error output are in plain text, so that we don't have to decode the
bug report in order to tell who should take care of it.  A meaningful
subject indicating language and platform also helps.</p>

<p>Please avoid posting an archive (.tar, .shar or .zip); we generally
need just a single file to reproduce the bug (the .i/.ii preprocessed
file), and, by storing it in an archive, you're just making our
volunteers' jobs harder.  Only when your bug report requires multiple
source files to be reproduced should you use an archive.  In any case,
make sure the compiler version, error message, etc, are included in
the body of your bug report as plain text, even if needlessly
duplicated as part of an archive.</p>

<p>The gcc lists have message size limits (200 kbytes) and bug reports
over those limits will currently be bounced.  If your bug is larger
than that, please post it directly in GNATS.</p>

<p>If you fail to supply enough information for a bug report to be
reproduced, someone will probably ask you to post additional
information (or just ignore your bug report, if they're in a bad day,
so try to get it right on the first posting :-).  In this case, please
post the additional information to the bug reporting mailing list, not
just to the person who requested it, unless explicitly told so.  If
possible, please include in this follow-up all the information you had
supplied in the incomplete bug report (including the preprocessor
output), so that the new bug report is self-contained.</p>



<h1><a name="manage">Managing Bugs (GNATS and the test-suite)</a></h1>

<p>This section contains information mostly intended for GCC
contributors.</p>

<p>If you find a bug, but you are not fixing it (yet):</p>
<ol>
<li>Create a (minimal) test-case.</li>
<li>Add the test-case to our test-suite, marking it as XFAIL.</li>
<li>Add a bug report referencing the test-case to GNATS.</li>
</ol>

<p>If you fix a bug for which there is already a GNATS entry:</p>
<ol>
<li>Remove the XFAIL on the test-case.</li>
<li>Close the bug report in GNATS.</li>
</ol>

<p>If you find a bug, and you are fixing it right then:</p>
<ol>
<li>Create a (minimal) test-case.</li>
<li>Add the test-case to our test-suite, marking it as PASS.</li>
<li>Check in your fixes.</li>
</ol>


<h1><a name="known">Frequently Reported Bugs in GCC 3.0</a></h1>

<h2>General</h2>

<p>The following bugs are very frequently reported.</p>

<ul>

<li>GCC 2.95.2 does not build on GNU/Linux systems using glibc 2.2,
such as Red Hat 7.0.  A <a href="install/glibc-2.2.patch">patch</a> is
available.  This will be fixed in GCC 2.95.3 and GCC 3.0.</li>

<li>GCC 2.95.2 crashes when compiling <code>mbx.c</code> from the PINE
4.30 or IMAP2000 distribution on Sparc systems running Solaris.</li>

</ul>

<h2>Fortran</h2>
<p> Fortran bugs are documented in the G77 manual rather than explicitly
listed here.  Please see <a href="onlinedocs/g77_bugs.html">"Known
Causes of Trouble with GNU Fortran"</a> in the
<a href="onlinedocs/g77_toc.html">G77 manual.</a>


<h2>C++</h2>

<p>This is the list of bugs (and non-bugs) in g++ (aka GNU C++) that
are reported very often, but not yet fixed. While it is certainly
better to fix bugs instead of documenting them, this document might
save people the effort of writing a bug report when the bug is already
well-known.  <a href="#report">How to report bugs</a> tells you how to
report a bug.

<p>There are many reasons why reported bugs don't get fixed. It might
be difficult to fix, or fixing it might break compatibility. Often,
reports get a low priority when there is a simple work-around. In
particular, bugs caused by invalid C++ code have a simple work-around,
<em>fix the code</em>. Now that there is an agreed ISO/ANSI standard
for C++, the compiler has a definitive document to adhere to. Earlier
versions might have accepted source code that is <em>no longer</em>
C++. This means that code which might have `worked' in a previous
version, is now rejected. You should update your code to be C++.

<p>You should try to use the latest stable release of the GNU C++
compiler. This is currently 3.0. Many commonly reported bugs in earlier
releases are fixed in that version.

<h3>Common problems updating from g++ 2.95 to g++ 3.0</h3>

<p>g++ 3.0 conforms much closer to the ISO C++ standard (available at
<a href="http://www.ncits.org/cplusplus.htm";>http://www.ncits.org/cplusplus.htm</a>).
We have also implemented some of the core and library defect reports (available at
<a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html";>http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html</a>
&amp; 
<a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html";>http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html</a> respectively).

<ul>

<li>The ABI has changed. This means that both class layout and name
mangling is different. You <em>must</em> recompile all c++ libraries (if
you don't you will get link errors).

<li>The standard library is much more conformant, and uses the
<code>std::</code> namespace.

<li><code>std::</code> is now a real namespace, not an alias for
<code>::</code>.

<li>The standard header files for the c library don't end with
<code>.h</code>, but begin with <code>c</code> (i.e.
<code>&lt;ctypes&gt;</code> rather than <code>&lt;types.h&gt;</code>).
The <code>.h</code> names are still available, but are deprecated.

<li><code>&lt;strstream&gt;</code> is deprecated, use
<code>&lt;stringstream&gt;</code> instead.

<li><code>streambuf::seekoff</code> &amp;
<code>streambuf::seekpos</code> are private, instead use
<code>streambuf::pubseekoff</code> &amp;
<code>streambuf::pubseekpos</code> respectively.

<li>If <code>std::operator (std::ostream &amp;, long long)</code>
doesn't exist, you need to recompile libstdc++ with
<code>--enable-long-long</code>.

</ul>

This means you may get lots of errors about things like
<code>strcmp</code> not being found. You've most likely forgotton to
tell the compiler to look in the <code>std::</code> namespace. There are
several ways to do this,

<ul>

<li>Say, <code>std::strcmp</code> at the call. This is the most explicit
way of saying what you mean.

<li>Say, <code>using std::strcmp;</code> somewhere before the call. You
will need to do this for each function or type you wish to use from the
standard library.

<li>Say, <code>using namespace std;</code> somewhere before the call.
This is the quick-but-dirty fix. This brings the <em>whole</em> of the
<code>std::</code> namespace into scope. <em>Never</em> do this in a
header file, as you will be forcing users of your header file to do the
same.

</ul>

<h3>Non-bugs</h3>
Here are some features that have been reported as bugs, but are not.

<dl>

<dt>Nested classes can access private types of the containing class.
<dd>G++ now implements type access control on member types. Defect
report 45 clarifies that nested classes are members of the class they
are nested in, and so are granted access to private members of that class.

<dt>Classes in exception specifiers must be complete types.
<dd>[15.4]/1 tells you that you cannot have an incomplete type, or
pointer to incomplete (other than <code><it>cv</it> void *</code>) in an
exception specification.

<dt>G++ emits two copies of constructors and destructors.
<dd>In general there are <em>three</em> types of constructor (and destructor).
<ol>
<li>The complete object constructor/destructor.
<li>The base object constructor/destructor.
<li>The allocating destructor/deallocating destructor.
</ol>
The first two are different, when virtual base classes are involved.
In some cases we can do better, and this is logged in GNATS.

<dt>Exceptions don't work in multithreaded applications
<dd>You need to rebuild g++ and libstdc++ with --enable-threads.
Remember, c++ exceptions are not like hardware interrupts. You cannot
throw an exception in one thread and catch it in another. You cannot
throw an exception from a signal handler, and catch it in the main
thread.

<dt>Global destructors are not run in the correct order
<dd>Global destructors should be run in the reverse order of their
constructors <em>completing</em>. In most cases this is the same as the
reverse order of constructors <em>starting</em>, but sometimes it is
different, and that is important. You need to compile and link your
programs with <code>--use-cxa-atexit</code>. We have not turned this
switch on by default, as it requires a <code>cxa</code> aware runtime
library (<code>libc</code>, <code>glibc</code>, or equivalent).

</dl>

<h3>Missing features</h3>
We know some things are missing from g++.

<dl>

<dt><code>export</code> is not implemented.
<dd>The keyword will be parsed correctly, but has no effect.

<dt>Two stage lookup in templates is not implemented.
<dd>[14.6] specifies how names are looked up inside a template. G++ does
not do this correctly, but for most templates this will not be noticeable.

<dt>

g<h3><a name="parsing"></a>Parse errors for "simple" code</h3> 

Up to and including GCC 3.0, the compiler will give "parse error" for
seemingly simple code, such as

<pre>
struct A{
  A();
  A(int);
  void func();
};

struct B{
  B(A);
  B(A,A);
  void func();
};

void foo(){
  B b(A(),A(1));     //Variable b, initialized with two temporaries
  B(A(2)).func();    //B temporary, initialized with A temporary
}
</pre>
The problem is that GCC starts to parse the declaration of
<CODE>b</CODE> as a function <CODE>b</CODE> returning <CODE>B</CODE>,
taking a function returning <CODE>A</CODE> as an argument. When it
sees the 1, it is too late. The work-around in these cases is to add
additional parentheses around the expressions that are mistaken as
declarations:
<pre>
  (B(A(2))).func();
</pre>
Sometimes, even that is not enough; to show the compiler that this
should be really an expression, a comma operator with a dummy argument
can be used:
<pre>
  B b((0,A()),A(1));
</pre>
<p>
Another example is the parse error for the <CODE>return</CODE>
statement in
<pre>
struct A{};

struct B{
  A a;
  A f1(bool);
};

A B::f1(bool b)
{
  if (b)
    return (A()); 
  return a;
}
</pre>
<p>The problem is that the compiler interprets <CODE>A()</CODE> as a
function (taking no arguments, returning <CODE>A</CODE>), and
<CODE>(A()</CODE>) as a cast - with a missing expression, hence the
parse error. The work-around is to omit the parentheses:
<pre>
  if (b)
    return A(); 
</pre>
<p>This problem occurs in a number of variants; in <CODE>throw</CODE>
statements, people also frequently put the object in parentheses. The
exact error also somewhat varies with the compiler version. The
work-arounds proposed do not change the semantics of the program at
all; they make them perhaps less readable.

<h3>Optimization at <code>-O3</code> takes a very long time</h3>
<p>At <code>-O3</code>, all functions are candidates for inlining. The
heuristic used has some deficiencies which show up when allowed such
freedom. This is g++ specific, as it has an earlier inliner than gcc.

</body>
</html>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]