[comp.lang.c++] C++ 2.1 differences

wmmiller@cup.portal.com (William Michael Miller) (06/27/90)

winston@fjcnet.GOV (Winston M. Llamas) writes:
> Can someone summarize the major changes in the language definitions between
> 2.0 and 2.1 C++ language specifications?

The following list of differences between the language defined in the 2.0
DRM and that of the 2.1 Reference Manual has been compiled jointly by Bjarne
Stroustrup and myself (I was the final editor, so don't blame Bjarne for my
mistakes! :-).  In most cases, Bjarne has told me whether the feature has
been implemented in the 2.1 cfront (I don't have a copy on which to
experiment) and I have indicated that status in brackets [] following the
description of the item.  Please note that these descriptions are
necessarily abbreviated; for complete details, see the official
documentation, "Unix System V AT&T C++ Language System Release 2.1 Product
Reference Manual, Select Code 307-159."  The features are presented in no
particular order.

1. Classes, enumerations, and typedefs defined within a class are now
considered to be local to the class (previously they were considered to have
occurred in the scope containing the class definition).  The resulting names
are accessible via explicit classname qualification (foo::bar), subject to
normal access control (public/protected/private).  The global scope operator
:: may be used with type names.  [This is implemented, but only in a
transitional manner: that is, the new syntax is accepted, but in cases in
which the meaning of a legal 2.0 program would be changed by application of
the new semantics, the old semantics are applied and a warning message is
issued.]

2. The definition of the circumstances in which it is permitted to convert a
pointer/reference-to-derived into a pointer/reference-to-base has been
expanded.  The previous definition required that the derived class be
publicly derived from the base; under the new definition, it is sufficient
that the function have access to the public members of the base class.  That
is, a member function or friend function of a privately-derived class can
convert a pointer/reference to that class into a pointer/reference to the
private base class.  [Implemented; apparently it always worked this way and
this is just a change to the definition.]

3. It is now allowed to pass an object of a class with a copy constructor to
an ellipsis function argument.  Doing so results in a bitwise copy of the
entire object, including hidden members such as virtual function and base
pointers, rather than an invocation of the copy constructor; in other words,
the result is *not* a valid, constructed object.  [Implemented.]

4. The correct syntax for deleting an array is "delete [] p;".  The former
syntax, in which an expression within the brackets was required to give the
number of elements in the array being deleted, is now officially an
anachronism.  [Implemented.]

5. An object which is created under a condition (e.g., the object "c" in the
construction "if (x) for (C c=5;;)") can only be accessed within that
condition, and if it is an object of a class with a destructor, the
destructor is invoked at the end of the condition.  [Implemented; apparently
this is the way things worked in 2.0 and this is simply a clarification of
the definition.]

6. Reference initializations which require creation of a temporary (type
mismatch or initializer not an lvalue) are now permitted only for const
references.  [I forgot to ask whether this is implemented in 2.1 cfront;
sorry.]

7. The dominance relationship in virtual derivation now applies to types,
enumerations, and data members; it previously applied only to member
functions.  [Not implemented.]

8. The 2.0 definition required that a pure virtual function either be
defined or redeclared as pure in a derived class.  This restriction is now
relaxed so that pure virtual functions are implicitly inherited as pure
virtual functions; no redeclaration is required.  [Implemented.]

9. Invoking a pure virtual function from a constructor now results in
undefined behavior; previously, a runtime error was required.

10. A constructor, all of whose arguments have default values, now qualifies
as a default constructor, e.g., for array creation.  Previously, a
constructor which took no arguments was required.  [Not implemented.]

11. A copy constructor cannot be declared as taking an object of its class
as an argument (the previous definition was more extensive, requiring that
*no* constructor take an object of its class as an argument).

12. It is now allowed to use explicit constructor and destructor notation
for types without constructors and destructors (e.g., "new int()",
"int i(5)", and int::~int()).  Such usage does *not* imply the generation of
an implicit constructor or destructor.  [Not implemented.]

13. The global operator delete() can only be specified as taking a single
argument, not in the optional two-argument form allowed for class member
operator delete().  [I don't know whether this is implemented or not.]

14. The definition of conversion and initialization has been greatly
clarified; I don't think the 2.1 definition is actually different from the
2.0 definition, but then again I didn't understand the 2.0 definition, so I
could be wrong. :-)

15. Function overload resolution has been changed in several ways.
Conversion to a reference now plays no part in overload resolution.  The
idea that a function requiring only standard conversions is to be preferred
has been removed.  It is no longer sufficient simply to have a single member
in "the intersection of sets of functions that best match on each argument;"
instead, it is also required that "the function thus selected must be a
strictly better match for at least one argument than every other possible
function (but not necessarily the same argument for each function)."  [I
don't know the state of implementation of these new rules.]

16. If operator++() or operator--() are invoked as postfix operators, the
program must supply a separate definition of the operator with an extra int
argument (which will be set to 0).  [Not implemented.]

17. Access control labels (public:/private:) are now permitted in unions.
[Implemented.]

18. It is no longer permitted to use the delete operator on a pointer to a
const.  ["Partly" implemented; Bjarne didn't elaborate.]

19. A function first mentioned in a friend declaration is given extern
status by default and therefore cannot later be declared as static.
[Implemented.]

20. It is now permitted to declare a base class protected; previously only
public and private derivation were allowed.  In protected derivation, the
public (and protected?) members of the base class become protected members
of the derived class.  [Not implemented.]

21. If operator new() is invoked with a zero first argument, implying a
zero-sized object, a pointer to an object is returned, and multiple such
invocations all return unique values.

22. It is now possible to have an array of references.

[The following changes are present in Ellis and Stroustrup, "Annotated C++
Reference Manual," but not in the cfront 2.1 documentation:]

23. It is now permitted to refer to nested types with multiply-qualified
names, e.g., "foo::bar::mumble."

24. The change allowing arrays of references was short-lived and has now
been rescinded.

------------------------------------------------------------------------------
William M. Miller, Glockenspiel, Inc.; P. O. Box 366, Sudbury, MA 01776-0003
wmmiller@cup.portal.com         BIX: wmiller            CI$: 72105,1744