Red Hat at the ISO C++ Standards Meeting (June 2016, Oulu): Core Language

It was quite a trek to get to Oulu, Finland for the June 2016 C++ Standards Committee meeting, but we were warmly received and the meeting went well once we arrived. We had very pleasant weather most of the week, and it was fun to experience the midnight sun, even though it played havoc with my sleep schedule.

The main order of business at this meeting was to vote on a first Committee Draft (CD) of the (expected) C++17 standard, ideally with as much as possible of the work that has been moving through the pipeline. The Core and especially the Library working groups were very effective at moving through their workload of papers at this meeting: Core ended the week with no papers left to review, and Library got through ~50 papers and had only two left at the end.

As usual, the committee divided into multiple working groups: the primary groups that met throughout the week are Core language, language Evolution, Library, Library Evolution, and Parallelism/Concurrency (SG1). Also as usual, I spent the week in the Core language working group.

In my report on the Jacksonville C++ Meeting last February, I described various proposals that were working through the committee. Of the core language features I listed there as expected or hoped to make it into C++17 at this meeting, almost all did. Note that as of this writing the final revisions of the adopted papers have not been posted publicly yet, but the links should adjust when they are.

P0035, ‘new’ of over-aligned data.
P0091, Template argument deduction for class templates.
P0292, constexpr if.
P0296 and P0299, Torvald’s forward progress guarantees papers.
P0386, Inline variables.
P0145, Refining expression evaluation order. As I mentioned in my Jacksonville report, I was concerned about one aspect of this paper, the requirement that function arguments be evaluated from left to right; GCC currently evaluates them from right to left on x86_64, because that’s more natural for the function call psABI. Before the meeting I implemented the proposed requirement and found a 2% performance penalty on one of the SPEC2006 tests; based on this I argued for relaxing that requirement of the paper to say that the arguments are indeterminately sequenced, as in the alternative offered near the end of the paper. After some discussion, the committee decided to adopt my position.

A few more features also made it in, that I hadn’t been aware of after Jacksonville:

P0028, using attribute namespace to avoid repetition.

  [[using gnu: may_alias, packed ]]

P0127, Declaring non-type parameters with auto.

  template <auto X> struct A { ... };
  A<42> aint;     // X has type int
  A<&aint> aaptr; // X has type A<42>*

P0217, structured bindings, similar to a Perl list assignment.

  struct A { int i, j; } f();
  auto [ x, y ] = f(); // declares x and y to refer to the members of the f return value

P0305, selection statement initializers, basically adding for-init-statements to if and switch. A simple thing, but I’ve been wishing for it for years.

  if (auto x = current_state();
    { x.do_more_stuff(); }

And people have been enthusiastic about combining this with structured bindings:

  if (auto [ x, y ] = f(); 
      x < 42)
    { /* use y */; }

However, a few expected features didn’t make it:

P0003, Removing deprecated C++98 dynamic exception-specifications. This just ran out of time; it was one of the papers that Library weren’t able to get to before the end of the meeting. But this should have no impact on users, it’s just a cleanup.

P0221, Default comparisons. This came up for a vote on Friday, but there was concern about the proposal not providing any way for a programmer to opt in or out of the default comparisons; either your class is simple enough that you get them, or you don’t. I expect that there will be a revised proposal early in the next standard cycle.

P0251, Unified function call syntax. After the last proposal was defeated at Jacksonville, there was no new proposal to consider at Oulu.

At the end of the week we voted to submit the first public review draft (CD) to ISO; the next meeting is in Issaquah, WA in November, at which we will start dealing with comments from the national bodies.

Join the Red Hat Developer Program (it’s free) and get access to related cheat sheets, books, and product downloads.



Leave a Reply