Red Hat at the ISO C++ Standards Meeting (February 2014)

Red Hat has actively participated in the ISO group defining the C++ standard for many years, and continues to make a significant contribution. The Red Hat toolchain team was well-represented at the February 2014 meeting of the standardization committee (JTC1/SC22/WG21) in Issaquah, WA, USA. In this article, Jason Merrill summarizes the main highlights and developments of interest to Red Hat’s customers and partners:

In February, Red Hat sent three engineers to the C++ standards committee meeting in Issaquah, WA.  The committee had dealt with most of the national body comments on the post-Bristol Committee Draft of C++14 at the previous meeting in Chicago, so this meeting was largely about putting the finishing touches on and addressing a few more National Body comments.

As usual, Red Hat was represented in the Core Language working group, the Evolution working group (notably supporting review of the Concepts Lite paper since the proposal is being developed together with the GCC implementation) and the Library working group, among others.  Since we spent the Chicago meeting processing National Body comments, we had a backlog of normal issues to get through; we reviewed a lot of proposed resolutions at the meeting, of which I provided drafting for 20 issues.

Several of the issues we were looking at were relevant to optimization:

  • One of them was my drafting for issue 1338, clarifying that the optimizer is allowed to treat ::operator new (size_t) like malloc, and assume the return value can’t alias anything.  Other GCC folks have been asking for this for a while.
  • Another was 1766, which made converting a value outside the range of values of an enumeration undefined behavior.  This basically reverses the earlier resolution of issue 1094, which I had raised in response to GCC BZ c++/42810 (optimizing away loop exit tests with enums).  I see no need to change the compiler to match, but it seems that other compilers do and will continue to optimize that way, so this will be important to check with gcc’s Undefined Behavior Sanitizer (ubsan).
  • 1776 has to do with the language in 3.8 specifying that if an object (or subobject) is created with a const or reference type, a compiler is allowed to assume that its value never changes.  This is problematic for the optional<T> class in the Library Fundamentals Technical Specification, which wants to be able to destroy its subobject and then construct a new one in its place, which leads to undefined behavior if T happens to have a const or reference field.  Core decided to deal with this by passing the pointer through a function (tentatively named “launder“) to break its association with any knowledge about an object; optional<T> will need to use that whenever returning a pointer to its subobject.
  • We also dealt with some refinement of the C++14 permission for the compiler to combine multiple new/delete pairs into a single allocation, or even to replace them with stack allocation.  A Google representative was saying that this is very beneficial for functions with a bunch of std::strings as local variables.

Getting away from optimization issues, we also reviewed my drafting to allow deduction of an array type from a C++11 brace-enclosed initializer list.

We’ve been changing handling of an initializer list with a single element to be just expressing direct-initialization from that element when that makes sense.  In response to a National Body comment from Finland, it looks like we’re going to drop deduction of std::initializer_list for C++11 ‘auto‘ in the case where there is no ‘=‘ in the initializer clause, i.e.

auto x { 42 };

will now deduce ‘int‘ rather than ‘std::initializer_list<int>‘.

We keep refining the specification of reference binding in 8.5.3; hopefully my latest drafting actually expresses what we want it to.

We seem to be backing off uniqueness of string literals in inline functions, because it wasn’t widely implemented.

At the end of the week, voting went very smoothly; Red Hat was actually the only organization that raised any discussion of the motions.  We abstained from a couple of the motions because they call for modifying the ABI of existing standard library classes in a Technical Specification, which seems inappropriate. I expect that this will be fixed at the meeting in June.

Thanks to Jason Merrill of Red Hat’s toolchain team for this summary.

Join Red Hat Developers, a developer program for you to learn, share, and code faster – and get access to Red Hat software for your development.  The developer program and software are both free!


Take advantage of your Red Hat Developers membership and download RHEL today at no cost.

Leave a Reply