Journal Articles

CVu Journal Vol 28, #1 - March 2016
Browse in : All > Journals > CVu > 281 (11)

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: Standards Report

Author: Martin Moene

Date: 05 March 2016 20:32:38 +00:00 or Sat, 05 March 2016 20:32:38 +00:00

Summary: Jonathan Wakely reports from the latest C and C++ meetings.

Body: 

Shortly after I wrote my last report [1], the C and C++ committees both met, back to back, in Kona, Hawaii. This report covers both, but as I only attended the C++ meeting the C news is based on notes from my colleague Martin Sebor. Any misrepresentation of that meeting will be my mistake.

Hawaii seemed nice, although I barely left the hotel where the meeting happened and would have liked to spend some more time there. The views of the ocean were very pleasant, and I did go for a walk in the midday sun to find a post office one day, but I’m sure Hawaii has more to offer!

The full minutes of the C++ meeting are on the WG21 website in the document N4558 [2] but this report will cover what I thought were some of the highlights. Much to my surprise, we got a variant compromise! Before the meeting I thought the different expectations of a variant type (similar to Boost.Variant) would cause endless debate, but following a very productive evening session in Kona everyone agreed on a design that still allows variants to enter an invalid state, but that state is not toxic and doesn’t lead to undefined behaviour if you so much as glance at it.

If you’ve been following C++ standards work recently you’ll know that much of the committee’s output is in the form of Technical Specifications (TS), where more experimental features are being specified, without the full formality (and finality) of an ISO standard. Following Kona the second version of the Library Fundamentals TS was finished and sent out for national body ballot. That includes everything in the first version plus two new wrapper types (propagate_const and observer_ptr), a functor for negating the result of other functions (not_fn), a simple API for the C++ random number facilities (randint), algorithms for erasing from containers (erase and erase_if), numerical functions for calculating GCD and LCM (gcd and lcm), a helper for writing values to a stream with a delimiter, solving the ‘fencepost problem’ (ostream_joiner) and metaprogramming traits for logical operations (conjunction, disjunction, negation). A second version of the Parallelism TS has been started, which adds Task Blocks to the first version. The Ranges and Networking proposals have progressed from proposals to working drafts, which basically means we think they’re in pretty good shape and can now be polished and start the process of becoming a TS. The Evolution Working Group (EWG) decided to go ahead with a TS on Modules, one of the most eagerly anticipated features for C++. There are already some prototype implementations in the Microsoft and Clang compilers, but following different designs. A TS will mean we get a single direction that all compilers can implement, and users will be able to use modules in cross-platform code.

EWG also made progress on unifying the unified call syntax proposals, and approved proposals on inline variables (allowing variables to be defined in headers without getting multiple definition errors [3]); making exception specifications part of a function’s type [4]; and preprocessor predicates for feature-testing (Clang’s __has_include macro for testing whether a header file exists [5]). That means you can expect those features to make it into some future C++ standard. There are discussions happening about specifying the order of evaluation in some expressions but that work will resume in Jacksonville.

The Core WG spent a long time thinking about what an object is, when a region of memory becomes a live object, when an object’s lifetime ends and the memory region returns to raw bytes. A new function called std::launder was proposed, which is a no-op but informs the compiler that whatever it knew about an object at an address should be forgotten about, which can be used after using placement new to create a new object where another one used to be. After the meeting it was pointed out that some industries might have trouble convincing regulators that ‘launder’ is an appropriate identifier to have in their code. (A similar objection was raised to the function corrupted_by_exception used to check whether a variant has entered its invalid state, which I think is a shame as I was hoping someone would form a C++-themed death metal band with that name).

The week after the C++ meeting the C committee, WG14, met at the same location. The C meeting was 4 days long and attended by 20 people, with a much narrower focus than the many streams and wide-ranging topics at the C++ meeting. The minutes are in N1978 on the WG14 website [6].

WG14 are working on a fifth part of TS 18661, which aligns C with the latest IEEE 754 / ISO 60559 standards, work that has been taking place in a sub-group for some years. The new part of the TS might include support for floating point exceptions, something that WG14 has resisted doing for some time due to it being very different to traditional C error handling.

Michael Wong of IBM did a presentation on transactional memory, which is already the subject of a C++ TS. That was received positively, so C might get TM support as well. The CPLEX group presented their proposal for parallel programming extensions to C [7] which was also positively received, but needs more work before it would be ready to become a TS.

There was also discussion of a new C standard. ISO rules require renewing a standard every 10 years, so there are four years left to decide what should be included. It looks like there will be a "C1y" standard in a year or two, which will be C11 plus technical corrigenda (fixes for bugs in the standard). That will be followed by a "C2x" standard with more major changes. Possible changes being considered include: transactional memory; removing or restricting some sources of undefined behaviour (including some preprocessor changes that have already been approved for the C++ preprocessor, which in practice is almost always a single tool that serves as both the C and C++ preprocessor); improving the <threads.h> specification; and some clean up regarding volatile. There is also a suggestion to drop Annex K, which defines the bounds-checking interfaces such as strcpy_s. These are not widely implemented, and it's not even agreed that they are actually any safer or less error-prone than the original functions.

At the time of writing, the next WG21 meeting is the first week of March 2016 in Jacksonville, Florida, and the next WG14 meeting is mid-April in London.

References

[1] CVu 27-5, November 2015

[2] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4558.html

[3] http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4424.pdf

[4] http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0012r0.html

[5] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0061r0.html

[6] http://open-std.org/jtc1/sc22/wg14/www/docs/n1978.pdf

[7] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1966.pdf

Notes: 

More fields may be available via dynamicdata ..