Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (21 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28dir.info
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/BUGS

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    33
    44   The latest version of this document is always available at
    5    [1]http://www.gnu.org/software/gcc/bugs.html.
     5   [1]http://gcc.gnu.org/bugs.html.
    66     _________________________________________________________________
    77
     
    1616          + [8]Detailed bug reporting instructions when using a
    1717            precompiled header
    18      * [9]Managing Bugs (GNATS and the test-suite)
    19      * [10]Frequently Reported Bugs in GCC
    20           + [11]General
    21           + [12]Fortran
    22           + [13]C
    23           + [14]C++
    24                o [15]Common problems updating from G++ 2.95 to G++ 3.0
    25                o [16]Non-bugs
    26                o [17]Missing features
    27                o [18]Parse errors for "simple" code
    28                o [19]Optimization at -O3 takes a very long time
     18     * [9]Frequently Reported Bugs in GCC
     19          + [10]C++
     20               o [11]Missing features
     21               o [12]Bugs fixed in the upcoming 3.4 series
     22          + [13]Fortran
     23     * [14]Non-bugs
     24          + [15]General
     25          + [16]C
     26          + [17]C++
     27               o [18]Common problems when upgrading the compiler
    2928     _________________________________________________________________
    3029
    3130                                Reporting Bugs
    3231
    33    Our preferred way of receiving bugs is via the [20]GCC GNATS bug
    34    reporting system.
    35 
    36    Before you report a bug, please check the [21]list of well-known bugs
     32   The main purpose of a bug report is to enable us to fix the bug. The
     33   most important prerequisite for this is that the report must be
     34   complete and self-contained, which we explain in detail below.
     35
     36   Before you report a bug, please check the [19]list of well-known bugs
    3737   and, if possible in any way, try a current development snapshot. If
    3838   you want to report a bug with versions of GCC before 3.1 we strongly
     
    102102  Where to post it
    103103
    104    Please submit your bug report directly to the [22]GCC GNATS bug
    105    database. Only if this is not possible, mail all information to
    106    [23]bug-gcc@gnu.org or [24]gcc-bugs@gcc.gnu.org.
    107 
    108    The GCC lists have message size limits (200 kbytes) and bug reports
    109    over those limits will currently be bounced. If your bug is larger
    110    than that, please post it using the [25]GCC GNATS bug database.
     104   Please submit your bug report directly to the [20]GCC bug database.
     105   Alternatively, you can use the gccbug script that mails your bug
     106   report to the bug database.
     107   Only if all this is absolutely impossible, mail all information to
     108   [21]gcc-bugs@gcc.gnu.org.
    111109
    112110Detailed bug reporting instructions
    113111
    114    Please refer to the [26]next section when reporting bugs in GNAT, the
    115    Ada compiler, or to the [27]one after that when reporting bugs that
     112   Please refer to the [22]next section when reporting bugs in GNAT, the
     113   Ada compiler, or to the [23]one after that when reporting bugs that
    116114   appear when using a precompiled header.
    117115
     
    122120     gcc -v -save-temps all-your-options source-file
    123121
    124    Typically the preprocessed file (extension .i for C or .ii for C++)
    125    will be large, so please compress the resulting file with one of the
    126    popular compression programs such as bzip2, gzip, zip or compress (in
    127    decreasing order of preference). Use maximum compression (-9) if
    128    available. Please include the compressed preprocessor output in your
    129    bug report, even if the source code is freely available elsewhere; it
    130    makes the job of our volunteer testers much easier.
     122   Typically the preprocessed file (extension .i for C or .ii for C++,
     123   and .f if the preprocessor is used on Fortran files) will be large, so
     124   please compress the resulting file with one of the popular compression
     125   programs such as bzip2, gzip, zip or compress (in decreasing order of
     126   preference). Use maximum compression (-9) if available. Please include
     127   the compressed preprocessor output in your bug report, even if the
     128   source code is freely available elsewhere; it makes the job of our
     129   volunteer testers much easier.
    131130
    132131   The only excuses to not send us the preprocessed sources are (i) if
     
    149148
    150149   Please avoid posting an archive (.tar, .shar or .zip); we generally
    151    need just a single file to reproduce the bug (the .i/.ii preprocessed
    152    file), and, by storing it in an archive, you're just making our
    153    volunteers' jobs harder. Only when your bug report requires multiple
    154    source files to be reproduced should you use an archive. In any case,
    155    make sure the compiler version, error message, etc, are included in
    156    the body of your bug report as plain text, even if needlessly
    157    duplicated as part of an archive.
     150   need just a single file to reproduce the bug (the .i/.ii/.f
     151   preprocessed file), and, by storing it in an archive, you're just
     152   making our volunteers' jobs harder. Only when your bug report requires
     153   multiple source files to be reproduced should you use an archive. This
     154   is, for example, the case if you are using INCLUDE directives in
     155   Fortran code, which are not processed by the preprocessor, but the
     156   compiler. In that case, we need the main file and all INCLUDEd files.
     157   In any case, make sure the compiler version, error message, etc, are
     158   included in the body of your bug report as plain text, even if
     159   needlessly duplicated as part of an archive.
    158160
    159161   If you fail to supply enough information for a bug report to be
     
    169171Detailed bug reporting instructions for GNAT
    170172
    171    See the [28]previous section for bug reporting instructions for GCC
     173   See the [24]previous section for bug reporting instructions for GCC
    172174   language implementations other than Ada.
    173175
     
    201203
    202204   When you have checked that your report meets these criteria, please
    203    submit it according to our [29]generic instructions. (If you use a
     205   submit it according to our [25]generic instructions. (If you use a
    204206   mailing list for reporting, please include an "[Ada]" tag in the
    205207   subject.)
     
    211213   the same GCC command again. If the bug happens again, the bug doesn't
    212214   really involve precompiled headers, please report it without using
    213    them by following the instructions [30]above.
     215   them by following the instructions [26]above.
    214216
    215217   If you've found a bug while building a precompiled header (for
    216218   instance, the compiler crashes), follow the usual instructions
    217    [31]above.
     219   [27]above.
    218220
    219221   If you've found a real precompiled header bug, what we'll need to
     
    225227   Please don't send us the actual precompiled header. It is likely to be
    226228   very large and we can't use it to reproduce the problem.
    227 
    228                    Managing Bugs (GNATS and the test-suite)
    229 
    230    This section contains information mostly intended for GCC
    231    contributors.
    232 
    233    If you find a bug, but you are not fixing it (yet):
    234     1. Create a (minimal) test-case.
    235     2. Add the test-case to our test-suite, marking it as XFAIL unless
    236        the bug is a regression.
    237     3. Add a bug report referencing the test-case to GNATS.
    238 
    239    If you fix a bug for which there is already a GNATS entry:
    240     1. Remove the XFAIL on the test-case.
    241     2. Close the bug report in GNATS.
    242 
    243    If you find a bug, and you are fixing it right then:
    244     1. Create a (minimal) test-case.
    245     2. Add the test-case to our test-suite, marking it as PASS.
    246     3. Check in your fixes.
    247229     _________________________________________________________________
    248230
    249231                        Frequently Reported Bugs in GCC
    250232
     233   This is a list of bugs in GCC that are reported very often, but not
     234   yet fixed. While it is certainly better to fix bugs instead of
     235   documenting them, this document might save people the effort of
     236   writing a bug report when the bug is already well-known.
     237
     238   There are many reasons why a reported bug doesn't get fixed. It might
     239   be difficult to fix, or fixing it might break compatibility. Often,
     240   reports get a low priority when there is a simple work-around. In
     241   particular, bugs caused by invalid code have a simple work-around: fix
     242   the code.
     243     _________________________________________________________________
     244
     245C++
     246
     247  Missing features
     248
     249   The export keyword is not implemented.
     250          Most C++ compilers (G++ included) do not yet implement export,
     251          which is necessary for separate compilation of template
     252          declarations and definitions. Without export, a template
     253          definition must be in scope to be used. The obvious workaround
     254          is simply to place all definitions in the header itself.
     255          Alternatively, the compilation unit containing template
     256          definitions may be included from the header.
     257
     258  Bugs fixed in the upcoming 3.4 series
     259
     260   The following bugs are present up to (and including) GCC 3.3.x. They
     261   have been fixed in 3.4.0.
     262
     263   Two-stage name-lookup.
     264          GCC did not implement two-stage name-lookup (also see
     265          [28]below).
     266
     267   Covariant return types.
     268          GCC did not implement non-trivial covariant returns.
     269
     270   Parse errors for "simple" code.
     271          GCC gave parse errors for seemingly simple code, such as
     272
     273struct A
     274{
     275  A();
     276  A(int);
     277};
     278
     279struct B
     280{
     281  B(A);
     282  B(A,A);
     283  void foo();
     284};
     285
     286A bar()
     287{
     288  B b(A(),A(1));  // Variable b, initialized with two temporaries
     289  B(A(2)).foo();  // B temporary, initialized with A temporary
     290  return (A());   // return A temporary
     291}
     292
     293          Although being valid code, each of the three lines with a
     294          comment was rejected by GCC. The work-arounds for older
     295          compiler versions proposed below do not change the semantics of
     296          the programs at all.
     297
     298          The problem in the first case was that GCC started to parse the
     299          declaration of b as a function called b returning B, taking a
     300          function returning A as an argument. When it encountered the 1,
     301          it was too late. To show the compiler that this should be
     302          really an expression, a comma operator with a dummy argument
     303          could be used:
     304
     305B b((0,A()),A(1));
     306
     307          The work-around for simpler cases like the second one was to
     308          add additional parentheses around the expressions that were
     309          mistaken as declarations:
     310
     311(B(A(2))).foo();
     312
     313          In the third case, however, additional parentheses were causing
     314          the problems: The compiler interpreted A() as a function
     315          (taking no arguments, returning A), and (A()) as a cast lacking
     316          an expression to be casted, hence the parse error. The
     317          work-around was to omit the parentheses:
     318
     319return A();
     320
     321          This problem occured in a number of variants; in throw
     322          statements, people also frequently put the object in
     323          parentheses.
     324     _________________________________________________________________
     325
    251326Fortran
    252327
    253328   Fortran bugs are documented in the G77 manual rather than explicitly
    254    listed here. Please see [32]Known Causes of Trouble with GNU Fortran
     329   listed here. Please see [29]Known Causes of Trouble with GNU Fortran
    255330   in the G77 manual.
    256331     _________________________________________________________________
    257332
     333                                   Non-bugs
     334
     335   The following are not actually bugs, but are reported often enough to
     336   warrant a mention here.
     337
     338   It is not always a bug in the compiler, if code which "worked" in a
     339   previous version, is now rejected. Earlier versions of GCC sometimes
     340   were less picky about standard conformance and accepted invalid source
     341   code. In addition, programming languages themselves change, rendering
     342   code invalid that used to be conforming (this holds especially for
     343   C++). In either case, you should update your code to match recent
     344   language standards.
     345     _________________________________________________________________
     346
     347General
     348
     349   Problems with floating point numbers - the [30]most often reported
     350          non-bug.
     351          In a number of cases, GCC appears to perform floating point
     352          computations incorrectly. For example, the C++ program
     353
     354#include <iostream>
     355
     356int main()
     357{
     358  double a = 0.5;
     359  double b = 0.01;
     360  std::cout << (int)(a / b) << std::endl;
     361  return 0;
     362}
     363
     364          might print 50 on some systems and optimization levels, and 49
     365          on others.
     366
     367          The is the result of rounding: The computer cannot represent
     368          all real numbers exactly, so it has to use approximations. When
     369          computing with approximation, the computer needs to round to
     370          the nearest representable number.
     371
     372          This is not a bug in the compiler, but an inherent limitation
     373          of the floating point types. Please study [31]this paper for
     374          more information.
     375     _________________________________________________________________
     376
    258377C
    259378
    260    The following are not bugs in the C compiler, but are reported often
    261    enough to warrant a mention here.
    262 
    263    Cannot initialize a static variable with stdin.
    264           This has nothing to do with GCC, but people ask us about it a
    265           lot. Code like this:
     379   Casting does not work as expected when optimization is turned on.
     380          This is often caused by a violation of aliasing rules, which
     381          are part of the ISO C standard. These rules say that a program
     382          is invalid if you try to access a variable through a pointer of
     383          an incompatible type. This is happening in the following
     384          example where a short is accessed through a pointer to integer
     385          (the code assumes 16-bit shorts and 32-bit ints):
    266386
    267387#include <stdio.h>
    268388
    269 FILE *yyin = stdin;
    270 
    271           will not compile with GNU libc (GNU/Linux libc6), because stdin
    272           is not a constant. This was done deliberately, to make it
    273           easier to maintain binary compatibility when the type FILE
    274           needs to be changed. It is surprising for people used to
    275           traditional Unix C libraries, but it is permitted by the C
    276           standard.
    277 
    278           This construct commonly occurs in code generated by old
    279           versions of lex or yacc. We suggest you try regenerating the
    280           parser with a current version of flex or bison, respectively.
    281           In your own code, the appropriate fix is to move the
    282           initialization to the beginning of main.
    283 
    284           There is a common misconception that the GCC developers are
    285           responsible for GNU libc. These are in fact two entirely
    286           separate projects; please check the [33]GNU libc web pages for
    287           details.
     389int main()
     390{
     391  short a[2];
     392
     393  a[0]=0x1111;
     394  a[1]=0x1111;
     395
     396  *(int *)a = 0x22222222; /* violation of aliasing rules */
     397
     398  printf("%x %x\n", a[0], a[1]);
     399  return 0;
     400}
     401
     402          The aliasing rules were designed to allow compilers more
     403          aggressive optimization. Basically, a compiler can assume that
     404          all changes to variables happen through pointers or references
     405          to variables of a type compatible to the accessed variable.
     406          Dereferencing a pointer that violates the aliasing rules
     407          results in undefined behavior.
     408
     409          In the case above, the compiler may assume that no access
     410          through an integer pointer can change the array a, consisting
     411          of shorts. Thus, printf may be called with the original values
     412          of a[0] and a[1]. What really happens is up to the compiler and
     413          may change with architecture and optimization level.
     414
     415          Recent versions of GCC turn on the option -fstrict-aliasing
     416          (which allows alias-based optimizations) by default with -O2.
     417          And some architectures then really print "1111 1111" as result.
     418          Without optimization the executable will generate the
     419          "expected" output "2222 2222".
     420
     421          To disable optimizations based on alias-analysis for faulty
     422          legacy code, the option -fno-strict-aliasing can be used as a
     423          work-around.
     424
     425          The option -Wstrict-aliasing (which is included in -Wall) warns
     426          about some - but not all - cases of violation of aliasing rules
     427          when -fstrict-aliasing is active.
     428
     429          To fix the code above, you can use a union instead of a cast
     430          (note that this is a GCC extension which might not work with
     431          other compilers):
     432
     433#include <stdio.h>
     434
     435int main()
     436{
     437  union
     438  {
     439    short a[2];
     440    int i;
     441  } u;
     442
     443  u.a[0]=0x1111;
     444  u.a[1]=0x1111;
     445
     446  u.i = 0x22222222;
     447
     448  printf("%x %x\n", u.a[0], u.a[1]);
     449  return 0;
     450}
     451
     452          Now the result will always be "2222 2222".
     453
     454          For some more insight into the subject, please have a look at
     455          [32]this article.
    288456
    289457   Cannot use preprocessor directive in macro arguments.
    290           Let me guess... you wrote code that looks something like this:
     458          Let me guess... you used an older version of GCC to compile
     459          code that looks something like this:
    291460
    292461  memcpy(dest, src,
     
    300469          and you got a whole pile of error messages:
    301470
    302      test.c:11: warning: preprocessing directive not recognized within
    303      macro arg
    304      test.c:11: warning: preprocessing directive not recognized within
    305      macro arg
    306      test.c:11: warning: preprocessing directive not recognized within
    307      macro arg
    308      test.c: In function `foo':
    309      test.c:6: undefined or invalid # directive
    310      test.c:8: undefined or invalid # directive
    311      test.c:9: parse error before `24'
    312      test.c:10: undefined or invalid # directive
    313      test.c:11: parse error before `#'
    314 
    315           Update: As of GCC 3.2 this kind of construct is always accepted
    316           and CPP will probably do what you expect, but see the manual
    317           for detailed semantics.
    318 
    319           However, versions of GCC prior to 3.2 did not allow you to put
    320           #ifdef (or any other directive) inside the arguments of a
    321           macro. Your C library's <string.h> happens to define memcpy as
    322           a macro - this is perfectly legitimate. The code therefore
    323           would not compile.
    324 
    325           This kind of code is not portable. It is "undefined behavior"
    326           according to the C standard; that means different compilers
    327           will do different things with it. It is always possible to
    328           rewrite code which uses conditionals inside macros so that it
    329           doesn't. You could write the above example
     471test.c:11: warning: preprocessing directive not recognized within macro arg
     472test.c:11: warning: preprocessing directive not recognized within macro arg
     473test.c:11: warning: preprocessing directive not recognized within macro arg
     474test.c: In function `foo':
     475test.c:6: undefined or invalid # directive
     476test.c:8: undefined or invalid # directive
     477test.c:9: parse error before `24'
     478test.c:10: undefined or invalid # directive
     479
     480          This is because your C library's <string.h> happens to define
     481          memcpy as a macro - which is perfectly legitimate. In recent
     482          versions of glibc, for example, printf is among those functions
     483          which are implemented as macros.
     484
     485          Versions of GCC prior to 3.3 did not allow you to put #ifdef
     486          (or any other preprocessor directive) inside the arguments of a
     487          macro. The code therefore would not compile.
     488
     489          As of GCC 3.3 this kind of construct is always accepted and the
     490          preprocessor will probably do what you expect, but see the
     491          manual for detailed semantics.
     492
     493          However, this kind of code is not portable. It is "undefined
     494          behavior" according to the C standard; that means different
     495          compilers may do different things with it. It is always
     496          possible to rewrite code which uses conditionals inside macros
     497          so that it doesn't. You could write the above example
    330498
    331499#ifdef PLATFORM1
     
    338506          style in addition to being more portable.
    339507
    340           In recent versions of glibc, printf is among the functions
    341           which are implemented as macros.
     508   Cannot initialize a static variable with stdin.
     509          This has nothing to do with GCC, but people ask us about it a
     510          lot. Code like this:
     511
     512#include <stdio.h>
     513
     514FILE *yyin = stdin;
     515
     516          will not compile with GNU libc, because stdin is not a
     517          constant. This was done deliberately, to make it easier to
     518          maintain binary compatibility when the type FILE needs to be
     519          changed. It is surprising for people used to traditional Unix C
     520          libraries, but it is permitted by the C standard.
     521
     522          This construct commonly occurs in code generated by old
     523          versions of lex or yacc. We suggest you try regenerating the
     524          parser with a current version of flex or bison, respectively.
     525          In your own code, the appropriate fix is to move the
     526          initialization to the beginning of main.
     527
     528          There is a common misconception that the GCC developers are
     529          responsible for GNU libc. These are in fact two entirely
     530          separate projects; please check the [33]GNU libc web pages for
     531          details.
    342532     _________________________________________________________________
    343533
    344534C++
    345535
    346    This is the list of bugs (and non-bugs) in g++ (aka GNU C++) that are
    347    reported very often, but not yet fixed. While it is certainly better
    348    to fix bugs instead of documenting them, this document might save
    349    people the effort of writing a bug report when the bug is already
    350    well-known. [34]How to report bugs tells you how to report a bug.
    351 
    352    There are many reasons why reported bugs don't get fixed. It might be
    353    difficult to fix, or fixing it might break compatibility. Often,
    354    reports get a low priority when there is a simple work-around. In
    355    particular, bugs caused by invalid C++ code have a simple work-around,
    356    fix the code. Now that there is an agreed ISO/ANSI standard for C++,
    357    the compiler has a definitive document to adhere to. Earlier versions
    358    might have accepted source code that is no longer C++. This means that
    359    code which might have `worked' in a previous version, is now rejected.
    360    You should update your code to be C++.
    361 
    362    You should try to use the latest stable release of the GNU C++
    363    compiler.
    364 
    365   Common problems updating from G++ 2.95 to G++ 3.0
    366 
    367    G++ 3.0 conforms much closer to the ISO C++ standard (available at
    368    [35]http://www.ncits.org/cplusplus.htm).
    369 
    370    We have also implemented some of the core and library defect reports
     536   Nested classes can access private members and types of the containing
     537          class.
     538          Defect report 45 clarifies that nested classes are members of
     539          the class they are nested in, and so are granted access to
     540          private members of that class.
     541
     542   G++ emits two copies of constructors and destructors.
     543          In general there are three types of constructors (and
     544          destructors).
     545
     546         1. The complete object constructor/destructor.
     547         2. The base object constructor/destructor.
     548         3. The allocating constructor/deallocating destructor.
     549
     550          The first two are different, when virtual base classes are
     551          involved.
     552
     553   Global destructors are not run in the correct order.
     554          Global destructors should be run in the reverse order of their
     555          constructors completing. In most cases this is the same as the
     556          reverse order of constructors starting, but sometimes it is
     557          different, and that is important. You need to compile and link
     558          your programs with --use-cxa-atexit. We have not turned this
     559          switch on by default, as it requires a cxa aware runtime
     560          library (libc, glibc, or equivalent).
     561
     562   Classes in exception specifiers must be complete types.
     563          [15.4]/1 tells you that you cannot have an incomplete type, or
     564          pointer to incomplete (other than cv void *) in an exception
     565          specification.
     566
     567   Exceptions don't work in multithreaded applications.
     568          You need to rebuild g++ and libstdc++ with --enable-threads.
     569          Remember, C++ exceptions are not like hardware interrupts. You
     570          cannot throw an exception in one thread and catch it in
     571          another. You cannot throw an exception from a signal handler
     572          and catch it in the main thread.
     573
     574   Templates, scoping, and digraphs.
     575          If you have a class in the global namespace, say named X, and
     576          want to give it as a template argument to some other class, say
     577          std::vector, then std::vector<::X> fails with a parser error.
     578
     579          The reason is that the standard mandates that the sequence <:
     580          is treated as if it were the token [. (There are several such
     581          combinations of characters - they are called digraphs.)
     582          Depending on the version, the compiler then reports a parse
     583          error before the character : (the colon before X) or a missing
     584          closing bracket ].
     585
     586          The simplest way to avoid this is to write std::vector< ::X>,
     587          i.e. place a space between the opening angle bracket and the
     588          scope operator.
     589
     590  Common problems when upgrading the compiler
     591
     592    ABI changes
     593
     594   The application binary interface (ABI) defines how the elements of
     595   classes are laid out, how functions are called, how function names are
     596   mangled etc. It usually changes with each major release (i.e. when the
     597   first or second part of the version number changes). You must
     598   recompile all C++ libraries, or you risk linker errors or
     599   malfunctioning programs. However, the ABI is not changed with bug-fix
     600   releases (i.e. when the third part of the version number changes). The
     601   code should be binary compatible among these versions.
     602
     603    Standard conformance
     604
     605   With each release, we try to make G++ conform closer to the ISO C++
     606   standard (available at [34]http://www.ncits.org/cplusplus.htm). We
     607   have also implemented some of the core and library defect reports
    371608   (available at
    372    [36]http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html &
    373    [37]http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html
     609   [35]http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html &
     610   [36]http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html
    374611   respectively).
    375      * The ABI has changed. This means that both class layout and name
    376        mangling is different. You must recompile all c++ libraries (if
    377        you don't you will get link errors).
     612
     613   Non-conforming legacy code that worked with older versions of GCC may
     614   be rejected by more recent compilers. There is no command-line switch
     615   to ensure compatibility in general, because trying to parse
     616   standard-conforming and old-style code at the same time would render
     617   the C++ frontend unmaintainable. However, some non-conforming
     618   constructs are allowed when the command-line option -fpermissive is
     619   used.
     620
     621   Two milestones in standard conformance are GCC 3.0 (including a major
     622   overhaul of the standard library) and the upcoming 3.4.0 version (with
     623   its new C++ parser).
     624
     625    New in GCC 3.0
     626
    378627     * The standard library is much more conformant, and uses the std::
    379        namespace.
    380      * std:: is now a real namespace, not an alias for ::.
     628       namespace (which is now a real namespace, not an alias for ::).
    381629     * The standard header files for the c library don't end with .h, but
    382630       begin with c (i.e. <cstdlib> rather than <stdlib.h>). The .h names
     
    388636       need to recompile libstdc++ with --enable-long-long.
    389637
    390    This means you may get lots of errors about things like strcmp not
    391    being found. You've most likely forgotten to tell the compiler to look
    392    in the std:: namespace. There are several ways to do this,
    393      * Say, std::strcmp at the call. This is the most explicit way of
    394        saying what you mean.
    395      * Say, using std::strcmp; somewhere before the call. You will need
    396        to do this for each function or type you wish to use from the
     638   If you get lots of errors about things like cout not being found,
     639   you've most likely forgotten to tell the compiler to look in the std::
     640   namespace. There are several ways to do this:
     641     * Say std::cout at the call. This is the most explicit way of saying
     642       what you mean.
     643     * Say using std::cout; somewhere before the call. You will need to
     644       do this for each function or type you wish to use from the
    397645       standard library.
    398      * Say, using namespace std; somewhere before the call. This is the
     646     * Say using namespace std; somewhere before the call. This is the
    399647       quick-but-dirty fix. This brings the whole of the std:: namespace
    400        into scope. Never do this in a header file, as you will be forcing
    401        users of your header file to do the same.
    402 
    403   ABI bugs
    404 
    405    3.0 had a new ABI, which affected class layout, function mangling and
    406    calling conventions. We had intended it to be complete, unfortunately
    407    some issues came to light, too late to fix in the 3.0 series. The ABI
    408    should not change in dot releases, so we addressed most issues in GCC
    409    3.1.
    410 
    411    Covariant return types
    412           We do not implement non-trivial covariant returns. We also
    413           generate incorrect virtual function tables for trivial
    414           covariance. Although trivial covariance will work, it is
    415           incompatible with the ABI. GNATS PR 3706 tracks this problem.
    416 
    417   Non-bugs
    418 
    419    Here are some features that have been reported as bugs, but are not.
    420 
    421    Nested classes can access private types of the containing class.
    422           G++ now implements type access control on member types. Defect
    423           report 45 clarifies that nested classes are members of the
    424           class they are nested in, and so are granted access to private
    425           members of that class.
    426 
    427    Classes in exception specifiers must be complete types.
    428           [15.4]/1 tells you that you cannot have an incomplete type, or
    429           pointer to incomplete (other than cv void *) in an exception
    430           specification.
    431 
    432    G++ emits two copies of constructors and destructors.
    433           In general there are three types of constructors (and
    434           destructors).
    435 
    436          1. The complete object constructor/destructor.
    437          2. The base object constructor/destructor.
    438          3. The allocating destructor/deallocating destructor.
    439 
    440           The first two are different, when virtual base classes are
    441           involved. In some cases we can do better, and this is logged in
    442           GNATS.
    443 
    444    Exceptions don't work in multithreaded applications.
    445           You need to rebuild g++ and libstdc++ with --enable-threads.
    446           Remember, c++ exceptions are not like hardware interrupts. You
    447           cannot throw an exception in one thread and catch it in
    448           another. You cannot throw an exception from a signal handler,
    449           and catch it in the main thread.
    450 
    451    Global destructors are not run in the correct order.
    452           Global destructors should be run in the reverse order of their
    453           constructors completing. In most cases this is the same as the
    454           reverse order of constructors starting, but sometimes it is
    455           different, and that is important. You need to compile and link
    456           your programs with --use-cxa-atexit. We have not turned this
    457           switch on by default, as it requires a cxa aware runtime
    458           library (libc, glibc, or equivalent).
    459 
    460    Problems with floating point computations.
    461           In a number of cases, GCC appears to perform floating point
    462           computations incorrectly. For example, the program
    463 
    464      #include <iostream>
    465      int main() {
    466      double min = 0.0;
    467      double max = 0.5;
    468      double width = 0.01;
    469      std::cout << (int)(((max - min) / width) - 1) << std::endl;
    470      }
    471 
    472           might print 49 on some systems and optimization levels, and 48
    473           on others.
    474 
    475           The is the result of rounding: The computer cannot represent
    476           all real numbers exactly, so it has to use approximations. When
    477           computing with approximation, the computer needs to round to
    478           the nearest representable number.
    479 
    480           This is not a bug in the compiler, but an inherent limitation
    481           of the float and double types. Please study [38]this paper for
    482           more information.
    483 
    484    Templates, scoping, and digraphs.
    485           If you have a class in global namespace, say named X, and want
    486           to give it as a template argument to some other class, say
    487           std::vector, then this here fails with a parser error:
    488           std::vector<::X>.
    489 
    490           The reason is that the standard mandates that the sequence <:
    491           is treated as if it were the token [, and the parser then
    492           reports a parse error before the character : (by which it means
    493           the second colon). There are several such combinations of
    494           characters, and they are called digraphs.
    495 
    496           The simplest way to avoid this is to write std::vector< ::X>,
    497           i.e. place a space between the opening angle bracket and the
    498           scope operator.
    499 
    500   Missing features
    501 
    502    We know some things are missing from G++.
    503 
    504    The export keyword is not implemented.
    505           Most C++ compilers (G++ included) do not yet implement export,
    506           which is necessary for separate compilation of template
    507           declarations and definitions. Without export, a template
    508           definition must be in scope to be used. The obvious workaround
    509           is simply to place all definitions in the header itself.
    510           Alternatively, the compilation unit containing template
    511           definitions may be included from the header.
    512 
    513    Two stage lookup in templates is not implemented.
    514           [14.6] specifies how names are looked up inside a template. G++
    515           does not do this correctly, but for most templates this will
    516           not be noticeable.
    517 
    518   Parse errors for "simple" code
    519 
    520    Up to and including GCC 3.0, the compiler will give "parse error" for
    521    seemingly simple code, such as
    522 struct A{
    523   A();
    524   A(int);
    525   void func();
     648       into scope. Never do this in a header file, as every user of your
     649       header file will be affected by this decision.
     650
     651    New in GCC 3.4.0
     652
     653   The new parser brings a lot of improvements, especially concerning
     654   name-lookup.
     655     * The "implicit typename" extension got removed (it was already
     656       deprecated since GCC 3.1), so that the following code is now
     657       rejected, see [14.6]:
     658
     659template <typename> struct A
     660{
     661    typedef int X;
    526662};
    527663
    528 struct B{
    529   B(A);
    530   B(A,A);
    531   void func();
     664template <typename T> struct B
     665{
     666    A<T>::X          x;  // error
     667    typename A<T>::X y;  // OK
    532668};
    533669
    534 void foo(){
    535   B b(A(),A(1));     //Variable b, initialized with two temporaries
    536   B(A(2)).func();    //B temporary, initialized with A temporary
     670B<void> b;
     671
     672     * For similar reasons, the following code now requires the template
     673       keyword, see [14.2]:
     674
     675template <typename> struct A
     676{
     677    template <int> struct X {};
     678};
     679
     680template <typename T> struct B
     681{
     682    typename A<T>::X<0>          x;  // error
     683    typename A<T>::template X<0> y;  // OK
     684};
     685
     686B<void> b;
     687
     688     * We now have two-stage name-lookup, so that the following code is
     689       rejected, see [14.6]/9:
     690
     691template <typename T> int foo()
     692{
     693    return i;  // error
    537694}
    538695
    539    The problem is that GCC starts to parse the declaration of b as a
    540    function b returning B, taking a function returning A as an argument.
    541    When it sees the 1, it is too late. The work-around in these cases is
    542    to add additional parentheses around the expressions that are mistaken
    543    as declarations:
    544   (B(A(2))).func();
    545 
    546    Sometimes, even that is not enough; to show the compiler that this
    547    should be really an expression, a comma operator with a dummy argument
    548    can be used:
    549   B b((0,A()),A(1));
    550 
    551    Another example is the parse error for the return statement in
    552 struct A{};
    553 
    554 struct B{
    555   A a;
    556   A f1(bool);
     696     * This also affects members of base classes, see [14.6.2]:
     697
     698template <typename> struct A
     699{
     700    int i, j;
    557701};
    558702
    559 A B::f1(bool b)
    560 {
    561   if (b)
    562     return (A());
    563   return a;
    564 }
    565 
    566    The problem is that the compiler interprets A() as a function (taking
    567    no arguments, returning A), and (A()) as a cast - with a missing
    568    expression, hence the parse error. The work-around is to omit the
    569    parentheses:
    570   if (b)
    571     return A();
    572 
    573    This problem occurs in a number of variants; in throw statements,
    574    people also frequently put the object in parentheses. The exact error
    575    also somewhat varies with the compiler version. The work-arounds
    576    proposed do not change the semantics of the program at all; they make
    577    them perhaps less readable.
    578 
    579   Optimization at -O3 takes a very long time
    580 
    581    At -O3, all functions are candidates for inlining. The heuristic used
    582    has some deficiencies which show up when allowed such freedom. This is
    583    g++ specific, as it has an earlier inliner than gcc.
     703template <typename T> struct B : A<T>
     704{
     705    int foo1() { return i; }       // error
     706    int foo2() { return this->i; } // OK
     707    int foo3() { return B<T>::i; } // OK
     708    int foo4() { return A<T>::i; } // OK
     709
     710    using A<T>::j;
     711    int foo5() { return j; }       // OK
     712};
     713
     714   In addition to the problems listed above, the manual contains a
     715   section on [37]Common Misunderstandings with GNU C++.
    584716
    585717References
    586718
    587    1. http://www.gnu.org/software/gcc/bugs.html
     719   1. http://gcc.gnu.org/bugs.html
    588720   2. http://gcc.gnu.org/bugs.html#report
    589721   3. http://gcc.gnu.org/bugs.html#need
     
    593725   7. http://gcc.gnu.org/bugs.html#gnat
    594726   8. http://gcc.gnu.org/bugs.html#pch
    595    9. http://gcc.gnu.org/bugs.html#manage
    596   10. http://gcc.gnu.org/bugs.html#known
    597   11. http://gcc.gnu.org/bugs.html#general
    598   12. http://gcc.gnu.org/bugs.html#fortran
    599   13. http://gcc.gnu.org/bugs.html#c
    600   14. http://gcc.gnu.org/bugs.html#cplusplus
    601   15. http://gcc.gnu.org/bugs.html#updating
    602   16. http://gcc.gnu.org/bugs.html#nonbugs
    603   17. http://gcc.gnu.org/bugs.html#missing
    604   18. http://gcc.gnu.org/bugs.html#parsing
    605   19. http://gcc.gnu.org/bugs.html#-O3
    606   20. http://gcc.gnu.org/gnats.html
    607   21. http://gcc.gnu.org/bugs.html#known
    608   22. http://gcc.gnu.org/gnats.html
    609   23. mailto:bug-gcc@gnu.org
    610   24. mailto:gcc-bugs@gcc.gnu.org
    611   25. http://gcc.gnu.org/gnats.html
    612   26. http://gcc.gnu.org/bugs.html#gnat
    613   27. http://gcc.gnu.org/bugs.html#pch
    614   28. http://gcc.gnu.org/bugs.html#detailed
    615   29. http://gcc.gnu.org/bugs.html#where
    616   30. http://gcc.gnu.org/bugs.html#detailed
    617   31. http://gcc.gnu.org/bugs.html#detailed
    618   32. http://gcc.gnu.org/onlinedocs/g77/Trouble.html
    619   33. http://www.gnu.org/software/glibc/
    620   34. http://gcc.gnu.org/bugs.html#report
    621   35. http://www.ncits.org/cplusplus.htm
    622   36. http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html
    623   37. http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html
    624   38. http://www.validlab.com/goldberg/paper.ps
     727   9. http://gcc.gnu.org/bugs.html#known
     728  10. http://gcc.gnu.org/bugs.html#cxx
     729  11. http://gcc.gnu.org/bugs.html#missing
     730  12. http://gcc.gnu.org/bugs.html#fixed34
     731  13. http://gcc.gnu.org/bugs.html#fortran
     732  14. http://gcc.gnu.org/bugs.html#nonbugs
     733  15. http://gcc.gnu.org/bugs.html#nonbugs_general
     734  16. http://gcc.gnu.org/bugs.html#nonbugs_c
     735  17. http://gcc.gnu.org/bugs.html#nonbugs_cxx
     736  18. http://gcc.gnu.org/bugs.html#upgrading
     737  19. http://gcc.gnu.org/bugs.html#known
     738  20. http://gcc.gnu.org/bugzilla/
     739  21. mailto:gcc-bugs@gcc.gnu.org
     740  22. http://gcc.gnu.org/bugs.html#gnat
     741  23. http://gcc.gnu.org/bugs.html#pch
     742  24. http://gcc.gnu.org/bugs.html#detailed
     743  25. http://gcc.gnu.org/bugs.html#where
     744  26. http://gcc.gnu.org/bugs.html#detailed
     745  27. http://gcc.gnu.org/bugs.html#detailed
     746  28. http://gcc.gnu.org/bugs.html#new34
     747  29. http://gcc.gnu.org/onlinedocs/g77/Trouble.html
     748  30. http://gcc.gnu.org/PR323
     749  31. http://www.validlab.com/goldberg/paper.ps
     750  32. http://mail-index.NetBSD.org/tech-kern/2003/08/11/0001.html
     751  33. http://www.gnu.org/software/libc/
     752  34. http://www.ncits.org/cplusplus.htm
     753  35. http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html
     754  36. http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html
     755  37. http://gcc.gnu.org/onlinedocs/gcc/C---Misunderstandings.html
Note: See TracChangeset for help on using the changeset viewer.