IBM Z and LinuxONE - Languages - Group home

The View (or trip report) from the Nov 2010 C++ Standard meeting

By FANG LU posted Tue March 24, 2020 07:38 PM

  
In this meeting, Bjarne Stroustrup opined that "The Atomics have become unstable at Fermilab".. Of course, Fermilab is a wonderful place, where one of the first sub-atomic particle, the top-quark was discovered. The architecture of this facility stands out uniquely with pi-shaped main building, telephone poles, and Archimedean spiral pumping stations. Much of the facility is opened to public visit. The main mission of the Lab is one of keen interest to our future and that is the search for Dark matter, Dark Energy which of course can decide the fate of the Universe. In my past life as an astrophysicist, these were question which were of keen interest, but now surprisingly still captures my imagination.

Our mission, though somewhat less grand then the fate of cosmology, was to decide what to do about several controversial matters which were well known and well summarized in Anthony Williams blog:
http://www.justsoftwaresolutions.co.uk/cplusplus/cplusplus-standards-committee-mailing-october-2010.html

Recall in my last report that we hardly have any controversy in the August Rapperswil meeting. While that was not intentional, it merely reflected the process of National Body Comments in response to the Final Committee Draft. At Rapperswil, our first chance of seeing the NB comments meant we were very busy with triaging the comments, placing them immediately into specific categories of response types, sending them to the proper working groups, but also addressing basic ones, or ones that were obvious or non-controversial. Here is a breakdown of what was done in the August meeting.

In total, 519 comments were received. To date, 257 have been accepted as proposed, 18 have been accepted with modifications, 84 have been rejected, and 140 remain to be addressed. The detailed breakdown:


UnresolvedAcceptedModifiedRejectedTotal
CWG872439123
LWG12328525181
editor19167920215

CWG is Core Working Group. LWG is Library Working Group. The tag editor means the comment was editorial and can be addresed by the project editor, Pete Becker.

A summary of the NB comment status can be found in this document:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3162.html

There is also the believe that if we are to ratify a Standard in March 2011, then we need to deal with all major controversy in this meeting, whether we were near the Windy City or not politically. Some might even be cynical, and see this as the last opportunity to push through any last minute features. The reality as always is more complex.

What is happening to the C++ Standard is very similar to software delivery. The only difference is that we deliver a document of words, instead of bits and bytes. Well, at the most fundamental level, it is all bits and bytes. In some waterfall software development cycle, there is an integration stage whereby all the new features are brought together for the first time to see how they work together, and with legacy code. It is in this integration stage that the C++ Standard is grinding through. Just as in software delivery, there are always bugs that are found during this stage which requires serious deliberation.

If the problem is serious or pervasive, or hard to fix, then we might pull it out. While I am not saying that Concepts fall in this category and had these issues, it was one of the candidate that was pulled out. Some would argue that rvalue reference also is one of those, but in some cases, you might find that removing something can be more problematic then leaving something in surrounded by a scaffold of fixes. We will describe some of that scaffolding next.

Some bugs may be found to affect legacy code negatively, and may require a difficult choice of disabling from being available in the default mode, or reducing its wide ranging affect on legacy code through a narrowing of its effects. Again, not saying this is the problem, but Implicit Move Constructors were ones that had potential to break legacy C++ code, and it was decided that its effect should be narrowed, although many also argue for it to be pulled from the default mode by disabling implicit move constructor and move assignment operator generation, and let the user write them manually or use "=default" to request thegenerated version. Specifically, we will tighten the conditions for generating implicit moves.This revises the rules for when to generate a move constructor ormove assignment operator so thatif a user declares any of the standard member functions,the move destructor or move assignment operator is not generated.(That's only an approximation; see the paper for the precise rules.)That avoids implicit generation of move functions in some caseswhere that could break exception guarantees in existing code.The rules for the generated copy constructor and copy assignmentoperator are changed to mirror the rules for the move case by makingthe implicit generation deprecated in some cases. That avoidschanging the semantics of existing code but allows compilers tostart warning that classes should be changed to the new modelwhere if you declare any of the standard special members you shouldnot expect the others to be generated for you.

Other bugs may be the result of an unanticipated interaction between a new feature and existing state which offers an opportunity for lightening the user's burden. The implicit declaration of noexcept(true)  in destructors and deletes offers one such opportunity which while it sounds like good software engineering, have the potential now to break some user code on the edge. However, its soundness overrides most concerns and this was accepted. On destructors with no explicit exception specification,the exception specification that would have been determined for agenerated destructor is used. That is a refinement of the proposalof last time that all destructors simply get noexcept(true)by default. The new rule considers the destructors of all basesand members in determining the default; if any base or member hasa potentially-throwing destructor, the declared destructor getsnoexcept(false).SImilarly, we will make all deallocation functions (operator delete)noexcept(true) by default.. Specifically, generated destructors will merge the specification from its parents, so if the parents don't throw, then the child will not. This is now done implicitly for user destructors. Note that this is viral and as soon as any destructor throws, you will go all the way through. And when it throws it will terminate

Another class of bug is the interoperability of your code with other software. Atomics between C and C++ became just such a poster child as it became uncertain whether you could write a line of C atomics and it would mean the same thing or even compile in the same way in C++. C1x which will go to its first Committee draft soon, has chosen to use its own productive syntax (using keyword _Atomic). The application has some issues in compatibility in that not all atomic operations, mutexes are compatible between C and C++. This makes any attempt to paper over the differences inside a common header using a macro which redirects to C syntax if it is a C file, and redirects to a C++ syntax if it is a C++ file, problematic. In the end, it was decided to not assume any compatibility, and leave in a state similar to C++'s Complex classes and C's _Complex type, until we know for sure how C will approach it.

Finally, it is possible the existence of new features mean that your code might now require even more user intervention to actually take advantage of it. Such could be the example of implicitly deduced noexcept specifications, which could be onerous to write. But in this case the creation of a new feature (to deduce the noexcept specification) at this late stage was deemed to be more of a problem then what it solved. So the committee chose not to move ahead, although there is reasonable expectation that the feature would be revived in future ratification.

All the the solutions are needed to ensure that the Standard features works well with each other and with legacy code. This kind of fixes at the integration stage is common in software delivery and is no different here in the late stages of C++ Standard ratification. But it is a good idea to look through and understand which problems are the most serious and require immediate action, which feature need to be pulled out to give it more baked in time, or which needs to be enhanced, or which needs to be left alone because we all agree to accept the risk.

These are actions and risks all software developers, release managers, and large projects are familiar with. In the end, we think the user will get the best compromise, although you may not agree with this. Some have asked if the number of defects, churns and fixes means we should not ship, or delay the shipping of this standard. Let me say that the committee plans to address all NB comments as they did in the last Committee draft and this resulted in a significantly improved specification. This will happen with the FCD before it goes to the Final Draft International Standard (FDIS) in March 2011. At that time, the Standard will still have defects, and as long as they are not major and pervasive, we can move forward with dealing with them. Please comment if you feel otherwise, but look forward to the true birth of the new C++ Standard in 2011 if all goes well.
0 comments
1 view