📄 reno.texi
字号:
class B @{ @dots{} @};void f (A<B>);@end exampleUnder @samp{-fexternal-templates}, the definition of @samp{A<B>} ends upin the implementation file that includes @file{a.h}. Under@samp{-falt-external-templates}, the same definition ends up in theimplementation file that includes @file{b.h}.@itemYou can control explicitly where a template is instantiated, withouthaving to @emph{use} the template to get an instantiation. To instantiate a class template explicitly, write @samp{templateclass @var{name}<paramvals>}, where @var{paramvals} is a list of valuesfor the template parameters. For example, you might write@exampletemplate class A<int>@end exampleSimilarly, to instantiate a function template explicitly, write@samp{template @var{fnsign}} where @var{fnsign} is the particularfunction signature you need. For example, you might write@exampletemplate void foo (int, int)@end exampleThis syntax for explicit template instantiation agrees with recentextensions to the draft @sc{ansi} standard.@itemThe compiler's actions on @sc{ansi}-related warnings and errors havebeen further enhanced. The @samp{-pedantic-errors} option produceserror messages in a number of new situations: using @code{return} in anon-@code{void} function (one returning a value); declaring a localvariable that shadows a parameter (e.g., the function takes an argument@samp{a}, and has a local variable @samp{a}); and use of the @samp{asm}keyword. Finally, the compiler by default now issues a warning whenconverting from an @code{int} to an enumerated type. This is likely tocause many new warnings in code that hadn't triggered them before. Forexample, when you compile this code,@smallexample@groupenum boolean @{ false, true @};voidf ()@{ boolean x; x = 1; //@i{assigning an @code{int} to an @code{enum} now triggers a warning}@}@end group@end smallexample@noindentyou should see the warning ``@code{anachronistic conversion from integertype to enumeral type `boolean'}''. Instead of assigning the value 1,assign the original enumerated value @samp{true}.@end itemize@node Enhancements and bug fixes@section Enhancements and bug fixes@itemize @bullet@cindex nested types in template parameters@itemYou can now use nested types in a template parameter list, even if the nestedtype is defined within the same class that attempts to use the template.For example, given a template @code{list}, the following now works:@smallexamplestruct glyph @{ @dots{} struct stroke @{ @dots{} @}; list<stroke> l; @dots{}@}@end smallexample@cindex function pointers vs template parameters@itemFunction pointers now work in template parameter lists. Forexample, you might want to instantiate a parameterized @code{list} classin terms of a pointer to a function like this:@smallexamplelist<int (*)(int, void *)> fnlist;@end smallexample@item@c FIXME! Really no limit? Jason said "deeper than 9" now OK...Nested types are now handled correctly. In particular, there is nolonger a limit to how deeply you can nest type definitions.@item@sc{gnu} C++ now conforms to the specifications in Chapter 11 of the@sc{arm}, ``Member Access Control''.@itemThe @sc{ansi} C++ committee has introduced a new keyword @code{mutable}.@sc{gnu} C++ supports it. Use @code{mutable} to specify that someparticular members of a @code{const} class are @emph{not} constant. Forexample, you can use this to include a cache in a data structure thatotherwise represents a read-only database.@itemError messages now explicitly specify the declaration, type, orexpression that contains an error.@itemTo avoid copying and editing all system include files during @sc{gnu}C++ installation, the compiler now automatically recognizes systeminclude files as C language definitions, as if they were wrapped in@samp{extern "C" @{ @dots{} @}}.@itemThe compiler checks operator declarations more strictly. For example,you may no longer declare an @samp{operator +} with three arguments.@itemYou can now use template type arguments in the same templateparameter list where the type argument is specified (as well as in thetemplate body). For example, you may write@exampletemplate <class T, T t> class A @{ @dots{} @};@end example@itemDestructors are now available for all types, even built-in ones; forexample, you can call @samp{int::~int}. (Destructors for types like@code{int} do not actually do anything, but their existence provides alevel of generality that permits smooth template expansion in morecases.)@itemEnumerated types declared inside a class are now handled correctly.@itemAn argument list for a function may not use an initializer list for its defaultvalue. For example, @w{@samp{void foo ( T x = @{ 1, 2 @} )}} is not permitted.@itemA significant amount of work went into improving the ability of thecompiler to act accurately on multiple inheritance and virtualfunctions. Virtual function dispatch has been enhanced as well.@itemThe warning concerning a virtual inheritance environment with anon-virtual destructor has been disabled, since it is not clear thatsuch a warning is warranted.@itemUntil exception handling is fully implemented in the Reno-2 release, useof the identifiers @samp{catch}, @samp{throw}, or @samp{try} resultsin the warning:@smallexamplet.C:1: warning: `catch', `throw', and `try' are all C++ reserved words@end smallexample@itemWhen giving a warning or error concerning initialization of a member in aclass, the compiler gives the name of the member if it has one.@itemDetecting friendship between classes is more accurately checked.@itemThe syntaxes of @w{@samp{#pragma implementation "file.h"}} and@samp{#pragma interface} are now more strictly controlled. The compilernotices (and warns) when any text follows @file{file.h} in theimplementation pragma, or follows the word @samp{interface}. Any suchtext is otherwise ignored.@itemTrying to declare a template on a variable or type is now considered anerror, not an unimplemented feature.@itemWhen an error occurs involving a template, the compiler attempts totell you at which point of instantiation the error occurred, inaddition to noting the line in the template declaration which had theactual error.@itemThe symbol names for function templates in the resulting assembly fileare now encoded according to the arguments, rather than just beingemitted as, for example, two definitions of a function @samp{foo}.@itemTemplate member functions that are declared @code{static} no longerreceive a @code{this} pointer.@itemCase labels are no longer allowed to have commas to make up theirexpressions.@itemWarnings concerning the shift count of a left or right shift now tellyou if it was a @samp{left} or @samp{right} shift.@itemThe compiler now warns when a decimal constant is so large that itbecomes @code{unsigned}.@itemUnion initializers which are raw constructors are now handled properly.@itemThe compiler no longer gives incorrect errors when initializing aunion with an empty initializer list.@itemAnonymous unions are now correctly used when nested inside a class.@itemAnonymous unions declared as static class members are now handledproperly.@itemThe compiler now notices when a field in a class is declared both asa type and a non-type.@itemThe compiler now warns when a user-defined function shadows abuilt-in function, rather than emitting an error.@itemA conflict between two function declarations now produces an errorregardless of their language context.@itemDuplicate definitions of variables with @samp{extern "C"} linkage are nolonger considered in error. (Note in C++ linkage---the default---you maynot have more than one definition of a variable.)@itemReferencing a label that is not defined in any function is now an error.@itemThe syntax for pointers to methods has been improved; there are stillsome minor bugs, but a number of cases should now be accepted by thecompiler.@itemIn error messages, arguments are now numbered starting at 1, instead of0. Therefore, in the function @samp{void foo (int a, int b)}, theargument @samp{a} is argument 1, and @samp{b} is argument 2. There isno longer an argument 0.@itemThe tag for an enumerator, rather than its value, used as a defaultargument is now shown in all error messages. For example, @w{@samp{voidfoo (enum x (= true))}} is shown instead of @w{@samp{void foo (enum x (=1))}}.@itemThe @samp{__asm__} keyword is now accepted by the C++ front-end.@itemExpressions of the form @samp{foo->~Class()} are now handled properly.@itemThe compiler now gives better warnings for situations which result ininteger overflows (e.g., in storage sizes, enumerators, unaryexpressions, etc).@item@code{unsigned} bitfields are now promoted to @code{signed int} if thefield isn't as wide as an @code{int}.@itemDeclaration and usage of prefix and postfix @samp{operator ++} and@samp{operator --} are now handled correctly. For example,@smallexample@groupclass foo@{public: operator ++ (); operator ++ (int); operator -- (); operator -- (int);@};voidf (foo *f)@{ f++; // @i{call @code{f->operator++(int)}} ++f; // @i{call @code{f->operator++()}} f--; // @i{call @code{f->operator++(int)}} --f; // @i{call @code{f->operator++()}}@}@end group@end smallexample@itemIn accordance with @sc{arm} section 10.1.1, ambiguities and dominance are nowhandled properly. The rules described in section 10.1.1 are now fullyimplemented. @end itemize@node Problems with debugging@section Problems with debuggingTwo problems remain with regard to debugging:@itemize @bullet@itemDebugging of anonymous structures on the IBM RS/6000 host is incorrect.@itemSymbol table size is overly large due to redundant symbol information;this can make @code{gdb} coredump under certain circumstances. Thisproblem is not host-specific.@end itemize@node Plans@chapter Plans for Reno-2The overall goal for the second phase of the @sc{gnu} C++ RenovationProject is to bring @sc{gnu} C++ to a new level of reliability, quality,and competitiveness. As particular elements of this strategy, we intendto:@enumerate 0@itemFully implement @sc{ansi} exception handling.@itemWith the exception handling, add Runtime Type Identification(@sc{rtti}), if the @sc{ansi} committee adopts it into the standard.@itemBring the compiler into closer compliance with the @sc{arm} and the draft@sc{ansi} standard, and document what points in the @sc{arm} we do not yet comply,or agree, with.@itemAdd further support for the @sc{dwarf} debugging format.@itemFinish the work to make the compiler compliant with @sc{arm} Section 12.6.2,initializing base classes in declaration order, rather than in the orderthat you specify them in a @var{mem-initializer} list.@itemPerform a full coverage analysis on the compiler, and weed out unusedcode, for a gain in performance and a reduction in the size of the compiler.@itemFurther improve the multiple inheritance implementation in thecompiler to make it cleaner and more complete.@end enumerate@noindentAs always, we encourage you to make suggestions and ask questions about@sc{gnu} C++ as a whole, so we can be sure that the end of this projectwill bring a compiler that everyone will find essential for C++ and willmeet the needs of the world's C++ community.@include templates.texi@include gpcompare.texi@contents@bye
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -