C++ Standard

11 Posts tagged with the standard tag
0

Standards love to add things. They remove very little, but they do like to deprecate. This post will describe a collection of things that is heading that way, or not heading that way in C++ 0x.

In my posting on Intention to deprecate trigraphs in the next C++ Standard, we successfully demonstrated that much of the non-English speaking world will still need to rely on trigraphs as a way to get to UCN through "\" which may be inaccessible in some codepages. So we would object to deprecating it without an alternative.

In the last meeting in Santa Cruz, an alternative was proposed in Core issue 789:Replacing Trigraphs. In short, it does not so much deprecate trigraphs (which we like) as move trigraphs out of translation phase 1 so trigraphs are not recognized ahead of raw strings, but is still recognized ahead of other strings (as it is now). It seems that trigraph interaction with raw strings was always the real issue behind the original National Body comment. This interaction had become more prevalent because Raw strings are accepted as part of C++0x. This proposal will level the playing field to what it was again.

We reviewed the paper as a way of fixing the interaction of trigraphs and raw strings. We think the paper is ready to go, but we're holding it back because we're considering other approaches, including moving UCNs out of translation phase 1 or moving raw string recognition into phase 1.

We're still looking at deprecating exception specifications. Our current feeling is that we will deprecate them except for the ways of saying a function doesn't throw at all (e.g., the new noexcept feature, still being reviewed). This feature has been shown to be relatively useless since its inception.

We did a straw poll on deprecating or removing exported templates. I voted to support removal of export to reduce dialecting C++. However a straw poll in full committee seems to prefer deprecation. This feature has been implemented exactly by one company, and even their lead is not opposing its removal. We appreciate their selfless sense of the C++ community and appreciate their sacrifice in learning about why this feature was problematic. Sometimes, it does take doing to see the whole picture.

Finally, we deprecated the semantics of the register keyword. This keyword has been ignored by most compiler that I am aware of, so it is the right time to deprecate it.

As with all deprecation, have no fear. All compilers will generally continue to accept (and or ignore) these cases, so that your code will continue to compile.

0 Comments Permalink
0

The Library side brought about some of the most interesting changes. I already discussed the key discussions with respect to unifying the Asynchronous futures proposal in The View (or trip report) from the Oct 2009 C++ Standard meeting.

This resulted in a paper which will be published in the upcoming mailing (in about a week from now), which will show the approach on Asynchronous Call A Simple Asynchronous Call.

The key changes there were:

  • A restoration of the variadic thread and async functions. This restoration is a consequence of analysis and request of the British Standards Institute.
  • A convergence on the "as if a new thread" in the launching of asynchronous work. This change avoids undefined behavior arising from any delay in destroying thread-local variables, but requires careful implementation to avoid excessive overhead.
  • Removal of the is_ready, has_exception, and has_value query functions. The presence of these function requires still other functions in the synchronous case. Evolution Working Group direction is that the complexity in interface is as yet unjustified, and prudence dictates a smaller initial interface.
  • Unspecified behavior for the use of timed wait functions when the unique_future was created from a deferred async.
  • The conversion from unique_future to shared_future will execute any deferred work.
  • The use of an enum class to better clarify the launching policy.

The other papers which support this is a resolution of most of the futures issues from National Body comments in Issues on Futures (Rev. 1) . A future describes components that a C++ program can use to retrieve in one thread the result (value or exception) from a function that has run in another thread.

These components are not restricted to multi-threaded programs but can be useful in single-threaded programs as well.

The other resolved issues include:



  • moves swap from the <algorithm> header to <utility> to address UK 300 because swap has become a common utility operation with several common idioms relying on it




Most of these are motivated by National Body comments from CD1. This shows the effort and focus of the committee during these periods as we continue to resolve the almost 600 comments that was received from the September 2008 CD1 draft.

There is now plan to issue a second draft for comment (post removal of Concepts, and with the fixes like above from CD1 comments). This will be CD2 and will be aimed for release after the next meeting in March 2010, in Pittsburgh hosted by Carnegie Mellon.

I will describe in another post more details on the schedule changes which is now clearer and I have updated in the C/C++ Standard hub

0 Comments Permalink
0

Santa Cruz is a wonderful location for us to decide weighty matters such as how best to ship a C++ Standard with the overloaded number of issues. Normally a surfing town as I am told, I have not had a chance to even make it to the ocean shoreline as yet even though I am only mere blocks from it. So busy we are that let me waste no more time and recap.

1. P.J. Plauger (or Bill Plauger) has been the convener of the C++ meeting. There was an attempt to stop processing any new features in order to facilitate our promised shipping date for the Standard. The problem is what is new? Some issues are discovered late and are serious if not fixed. Some new issues are truly wish list and should be stopped. Other issues are somewhat in between but need to be weighted with all the other.

The vote that tried to stop all new feature failed probably because of how ambiguous the wording is, in my opinion. The issue isn't about stopping consideration of any new feature, but balancing all features based on their seriousness and only being able to handle a fixed number of them based on resource.

But the problem with that model of triage (which is often done in software industry), is that we are all volunteers and you just can't easily make volunteers do the hard thing, when they would rather do what they like.

The end result is that P.J. Plauger has tendered his resignation as convener. I and many would like to thank him for his service and his guidance which has enabled C++ meeting hostings well into 2011.

2. Both Evolution and Core Committees met in addition to Library. Evolution had to deal with a number of pending additions which had been long promised. The most significant discussion is the proposal to add Asynchronous and Futures to C++. This is a higher abstraction for concurrency that allows independent action with a return value.

This was controversial because there were two leading candidate proposals. The majority of the discussion allowed a unified proposal which offered:

  • A restoration of the variadic thread and async functions. This restoration is a consequence of analysis and request of the British Standards Institute.
  • A convergence on the "as if a new thread" in the launching of asynchronous work. This change avoids undefined behavior arising from any delay in destroying thread-local variables, but requires careful implementation to avoid excessive overhead.
  • Removal of the is_ready, has_exception, and has_value query functions. The presence of these function requires still other functions in the synchronous case. Evolution Working Group direction is that the complexity in interface is as yet unjustified, and prudence dictates a smaller initial interface.
  • Unspecified behavior for the use of timed wait functions when the unique_future was created from a deferred async.
  • The conversion from unique_future to shared_future will execute any deferred work.
  • The use of an enum class to better clarify the launching policy.

Interestingly, this discussion really only have bearing on two Library proposals which I will detail in a following blog post.


The formal motions for C++ Core language which resulted from this include the usual group of defect fixes, numbering into the 70 range. Basically, all Ready and Tentatively Ready issues of
n2962 except issues 799, 812, 861, 919, and 920.

There was also a paper called Reaching Scope of Lambda Expressions

n2998
Current lambdas restrict the referents of a lambda expression to the immediately-enclosing function or lambda expression. This restriction is severe and does damage to the utility of the lambda feature.

For example, a simple matrix multiplication kernal would require two enclosing scopes and there would be no captures. It is essentially equivalent to saying that the body of a nested loop cannot access function parameters.

Much of this is from the paper.

Consider the following function to multiply square matricies.


matrix operator*( const matrix& a, const matrix& b )
{
    int n = a.numrows();
    matrix c( n, n );
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) {
            double t = 0.0;
            for ( int k = 0; k < n; k++ ) {
                t += a[i][k] * b[k][j];
            }
            c[i][j] = t;
        }
    }
    return c;
}

Its rewrite into functions and lambdas, as intended by the adopted N2550, is as follows. Note that the rewrite is approximately the same size.


matrix operator*( const matrix& a, const matrix& b )
{
    int n = a.numrows();
    matrix c( n, n );
    for_range( 0, n-1, [&]( int i ){
        for_range( 0, n-1, [&]( int j ){
            double t = 0.0;
            for_range( 0, n-1, [&]( int k ){
                t += a[i][k] * b[k][j];
            } );
            c[i][j] = t;
        } );
    } );
    return c;
}

However this straightforward reformulation is ill-formed as per N2927 wording for 5.1.1 expr.prim.lambda paragraphs 9–12. To make the code well-formed, the function must be rewritten as follows, where inserted text shows new code, which sometimes alter variable references.

matrix operator*( const matrix& a, const matrix& b )
{
    int n = a.numrows( );
    matrix c( n, n );
    for_range( 0, n-1, [&]( int i ){
        const matrix& a1 = a;
        const matrix& b1 = b;
	int& n1 = n;
	matrix& c1 = c;
        for_range( 0, n1-1, [&]( int j ){
            const matrix& a2 = a1;
            const matrix& b2 = b1;
	    int& n2 = n1;
	    int& i2 = i;
            double t = 0.0;
            for_range( 0, n1-1, [&]( int k ){
                t += a2[i2][k] * b2[k][j];
            } );
            c1[i][j] = t;
        } );
    } );
    return c;
}

Such extensive mechanical editing will inhibit use, make errors more likely, and complicate code maintenance. Such editing is properly the domain of the compiler.

A third proposal n2989 "Unified Function Syntax" was not moved after significant discussion on whether it solved significant problem or not especially at this late stage, or just merely being a stylistic wish, especially if you have written large amounts of lambdas with the late specified return syntax and found current syntax ugly.

There was controversy because a previous proposal on auto lambda syntax was moved on the contingency that there would be room to explore a unified function syntax. However, as with all agreement in such a committee, the promise is always to allow the work to go forward with all the resource costs (such as authors and collaborators working together, review committee going over the proposal in this case over eight hours over several day), but there is no promise that it would be accepted. Such was the case, and of course the disappointment of the authors of this paper.

Well, in the next posting I will go over the Library proposal.

0 Comments Permalink
0

I am attending the C++ Standard meeting in Santa Cruz. We have a number of issues of interest to us.

SCARY iterators is a way to improve portability invented by our IBM Watson Lab and collaborated on with testing using the xlC++ compiler. It also can give significant performance gains, especially in Blue Gene software:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2913.pdf

The other issue of interest is continuing discussion on resolution to the Trigraph deprecation issue. Although the idea of deprecation was rejected in Frankfurt, there was a desire to reach a common solution by replacing trigraph with something else. A paper was produced and we will review it in the next meeting:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2978.pdf

The solution will resolve many of the issues in my previous posts about trigraphs but we do have some comments. On the whole, we are pleased with this compromise approach.

The other issues that will be discussed will be how to control the proliferation of issues that could cause a prolonged delay of publication of the Standard.

Like any software delivery, shipping a Standard meets the same problems in that there will be many late issues come up out of integration and testing. Some of those will be new, while others are critical fixes. All issues need to be considered fairly through a triage process to see whether they are critical enough to require fixing before shipping, or can afford to be delayed until post-shipping.

This process as obvious as it is to do is not something that is easy to do at the Standard level where work is voluntary. There will be repercussion to this as we move forward if we do not adequately resolve this.

0 Comments Permalink
0

The mailing for the July C++ Standard meeting has been released. For those who do not understand this process, this is basically where everyone writes up their work for the upcoming meeting so we have something concrete to discuss.

IBM has submitted 2 papers. One is a direct response to the proposed trigraph deprecation as discussed here:

http://www-949.ibm.com/software/rational/cafe/thread/2293?tstart=0
and
http://www-949.ibm.com/software/rational/cafe/blogs/cpp-standard/2009/06/03/intention-to-deprecate-trigraphs-in-the-next-c-standard

are posed in these papers:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2910.pdf

We have also submitted a paper based on IBM research:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2911.pdf

on how to improve compatibility between C++ library implementations for C++ iterators:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2913.pdf

I will say more on these papers in a future blog.

0 Comments Permalink
0

Do you use trigraphs?
If so, you may be interested that the C++ Standard Committee will vote to deprecate trigraphs (to Appendix D) in the next meeting in July 12-18 in Frankfurt as I discussed in my last trip report:
http://www-949.ibm.com/software/rational/cafe/blogs/cpp-standard/2009/05/27/the-view-or-trip-report-from-the-mar-2009-c-standard-meeting

Trigraph sequences are

??= # pound sign
??( [ left bracket
??) ] right bracket
??< { left brace
??> } right brace
??/ \ backslash
??’ ^ caret
??! | vertical bar
??- ~ tilde

One of the reason they were invented was because a character like '#' have code points that differ across EBCDIC code pages.
It is safe to use '?' and '=' because these share the same code point across all EBCDIC code pages.
Another reason is that on some international keybaords, these characters do not have representation and they must be typed in using this sequence of text. They get replaced in quotes because they are handled in phase 1 of translation and can be replaced even if found inside another token, such as a quoted string, or character constant.

There are some possible alternatives. Digraph supply a subset of trigraphs:


%: or %% # number sign
<: [ left bracket
:> ] right bracket
<% { left brace
%> } right brace
%:%: or %%%% ## token pasting


But it does not represent these trigraphs and cannot be a complete replacement:
??! |
??' ^
??/ \
??- ~

Digraphs also are handled during tokenization and must always be a full token by itself. This means it will not be replaced inside quotes.

Now you can use something like an alternative spelling for operators to cover 3 of those 4 cases:
bitor
or
or_eq
xor
xor_eq
compl

But one of those four, '\' truly has no replacement possibility.

Even in the ASCII world, the loss of trigraphs can be problematic if a keyboard does not have backslash. Does this happen? I would like to know.
Loss of backslash also can lead to other characters that are variant, including the half-width backslash in Japanese, and the yen sign in Shift-JIS.

So why is there enthusiasm for this deprecation?

It is precisely because of the ability to replace trigraphs in quotes. They can look like question marks, and in some cases they are especially when inside a quoted string. There is cause for confusion. Specifically, one National Body comment urge the removal of trigraphs because:
'Trigraphs are a complicated solution to an old problem, that cause more problems than they solve in the modern environment. Unexpected trigraphs in string literals and occasionally in comments can be very confusing for the non-expert. "

Are there others, I would like to know. Some folks have mentioned how this can be a problem is modern Perl searches.

I would be interested if you agree with these statements and what opinion you may have on the deprecation of trigraphs.

0 Comments Permalink
2

Hi, all. I apologize for the lack of updates as an addition to the family has kept me hopping. But just as important is where is the C++ Standard, so here is the long delayed trip report.

The C++ Meeting in Summit, NJ on Mar 1-6 was the first meeting we had after the draft release for public comment of the C++ 0x Standard. In this meeting, we addressed the various National Body comments based on the draft that was released in the September San Francisco meeting.

A list of the National Body Comments can be found here:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2837.pdf

Out of these National Body Comments, there were:

National Body Comments Unresolved Accepted Modified Rejected Total
Core Language 93 32 8 43 176
Library 128 36 5 35 204
Editorial 28 148 14 21 211
Total 249 216 27 99 591


As a rough count, there are :

  • Language
    • 70 features
    • 300 defects ( in the C++ Standard)
  • Runtime
    • 70 features
    • 230 defects ( in the C++ Standard)

That is a lot of features and a lot of defects. Not all the defects will be in every compiler, because some defects are just textual changes. Almost every compiler I know of will be doing a phased released approach, delivering all these across multiple releases.

One unnamed compiler vendor I spoke to at the recent BoostCon09 joked that it may not be all delivered until 2020. I didn't think he was joking, on reflection.

While I am on BoostCon09, I did a 90 minute talk on the Overview of C++0x and compiler support. The external trip report for that talk can be referenced here:
http://par-con.blogspot.com/
and here:
http://revergestudios.com/reblog/index.php?n=ReCode.BoostCon09
My trip report is here:
http://www-949.ibm.com/software/rational/cafe/blogs/ccpp-parallel-multicore/2009/05/25/the-view-trip-report-from-boostcon09
The video of the talk will be online soon.

From my point of view, the other significant thing that happened was a total rewrite of the section on lambdas. The CD1 version of lambda, a significant feature had no examples at all, and did not deal with many, many edge cases (such as how are arrays passed). This section and its design was discussed carefully and a new section will appear in the next draft, which will address many of these problems.

Another interesting discussion is the intent to deprecate various potentially unused C++ entities. These include the meaning of the register keyword, and trigraphs.

On the register keyword, the intent is to deprecate the meaning of the keyword, which used to be that variables qualified as register may be allocated to a register, at the discretion of the compiler. With today's sophisticated register allocator, this advice is rarely taken anyway, and the compiler often would make independent decision based on an abstract machine with a register file that is far greater then what is normally present.

The deprecation of this meaning is welcomed. The keyword will remain for use by for some future meaning.

On the deprecation of trigraphs, the thought process is that there is concern about the confusion when trigraphs are used in quotes with normal usages of question marks, since trigraphs often start with multiple question marks. This one is more problematic from my point of view as it is not clear how their use will be substitutable on international keyboards where such code pages are not present or is represented differently. It does not seem digraphs will replace all the pieces. I will describe more on this in a future post.

The latest draft as of May 25, 2009 is:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2857.pdf

You can get a really good idea of what is in the 0x CD1, that is different from the C++98/03 draft in this excellent document by Alisdair Meredith. I have not reviewed it for completeness, but it is a great resource:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2871.html

Bye for now, and I will post again real soon.

2 Comments Permalink
0

The next C++ Standard meeting is rapidly approaching. This meeting will be the first meeting after the Committee Draft (CD) for C++0x was released last year in September. A CD is like an alpha of the C++ Standard.

Since then, there has been one update to the CD in December with minor fixes:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2800.pdf

This will be the first meeting where we will process defects, and National body comments. Most people will be watching for any show stoppers which can cause a delay to the proposed schedule of the C++ Std as outlined at the right side panel of this blog.
http://www-949.ibm.com/software/rational/cafe/community/ccpp/standards

So far, from watching the discussion on the reflector, there has not been any major of note. But that does not preclude them from being discovered as we work through the comments and defects.

The C++ Std meeting is open to anyone, and if you are in the Summit New Jersey area (specifically Grand Summit Hotel), and is interested in contributing to the Standardization process, please drop by. But first you need to notify the convener. I can help with that.

As usual, IBM will be sending two representatives to this meeting. Both of us will represent the Canadian delegation.

0 Comments Permalink
0

Hi, I had the honor and pleasure of being invited to visit Professor Bjarne Stroustrup at Texas A & M University yesterday, delivering a talk on C++ in OpenMP:

http://parasol.tamu.edu/seminar/abstract.php?talk_id=586

I will say something more about this subject in the Parallel Computing blog. But I am interested in announcing something that Bjarne shared with me while I was in his office. This is a new C++0x FAQ which he is preparing on this page:

http://www.research.att.com/~bs/C++0xFAQ.html

I will put this link up as a permanent link on the front of this hub.

0 Comments Permalink
2

The Dawn of a new Standard

Posted by Michael_Wong Nov 18, 2008

We live in interesting times.

At no times is this more true then today's C++ as we move towards a new
Standard code named C++0x, to be released, tentatively 2009.

But x could be A, B, C, D, E, F ?:|

Hi, my name is Michael Wong. I am the Canadian C++ Standard
representative for evolution and language. Robert Klarer is the representative for
library. We would like to invite you to watch this blog for discussion on C++ Standard
happenings. We will use this space to file trip reports on the C++
Standard meetings, as well as interesting happenings in the C++ community.

With loads of new features in C++0x, such as Concepts, Concurrency,
move semantics, auto type inference, new initialization syntax, C++0x
will be promising big things. Can it deliver?

But that is not all. C++ has gone through a renaisance of ideas with
the support of Generic Programming, metaprogramming, and Boost
Libraries. How about functional programming, domain-specific languages or garbage collection?

So come back regularly, and watch the story as it develops.

Thanks.

2 Comments Permalink
0


Well, this is it!

In this meeting, we voted out a Committee Draft for the new C++0x,
which means all the work items are complete.This is like the C++0x
Standard going out as a Beta. A link to the draft C++ Standard is in
the Overview page under the Links section.

This draft will be available for public comment which we expect to take
all of 2009. The plan is that after addressing those public comments, the committee hope
to vote out a Final Committee Draft for more comments in 2010,
then its straight to the Final Draft International Standard, and then
it becomes an ISO Standard.

But those plans could change, if there are surprises in the comments.

You can find the link to draft in the forum section under C++0x Schedule


Its been 4 years of serious work, with the first item voted in 2004 in
Lillehammer. Here is a quick recap of what we did in the September 2008
meeting:

1. Concepts finally got voted into the core language part of the Working Draft.

Most of the standard library got conceptualized, too, but not all of
it. The rest of the library will get conceptualized over the course of
the next few meetings.

2. Yours truly's (Michael Wong's) paper on User-defined Literals
(formerly known as Extensible Literals) was finally voted into the core
language! This idea was initiated by IBM's Ian McIntosh.

3. Yours truly's (Michael Wong's) paper on attributes in C++ was also voted into the
core language.

3.1 Standard attributes for data-dependency ordering in multithreading
programs were added to the core language, by IBM's Paul Mckenney

4. The Working Draft was voted out as a Committee Draft for ISO ballot.
In about a year, the committee will issue a Final Committee Draft for
ISO ballot, and a year from that, the committee will issue a Final
Draft International Standard (FDIS). After the the FDIS ballot, the
FDIS will become the new International Standard, assuming nothing goes
wrong.

5. The Decimal TR was voted out for ISO ballot, by IBM's Robert Klarer

6. The special math functions from TR1 were voted out as the subject of
a Committee Draft that will eventually become its own International
Standard (i.e. the special math functions will not be in C++0x, but
they will be a separate standard).

7. The COW technique for implementing std::basic_string has been
outlawed in C++0x. This means that the std::string that we provide will
no longer be conforming in single-threaded mode (we don't currently do
Copy On Write/Reference Counting in multi-threaded mode because it's
not threadsafe).

8. You can now initialize non-static members of a class using C-style initializers syntax. Example:

int foo();

struct S {
static const int a = 1; // OK in C++2003, OK in C++0x
int b = 5; // Error in C++2003, OK in C++0x
int c = foo(); // Error in C++2003, OK in C++0x
struct C {
double real;
double imag;
};
// Initializer list:
C c_object = { 0.0, 0.0 }; // OK in C++0x
};

/* Equivalent to: (this is OK in C++2003)

struct S {
static const int a = 1;
S() : b(5), c(foo()), C_object(0.0, 0.0) {}
int b;
int c;
struct C {
double real;
double imag;
};
C c_object;
};

*/

9. enumerations can now be forward declared, as long as the compiler
has enough information to decide the underlying type of the enum

example:

enum my_colours : short; // forward declaration of my_enum with underlying type short int

// When you redeclare the enum, you have to restate the enum-base specifier:
enum my_colours : short { red = 0, green, blue, yellow };

10. A library was adopted for asynchronous futures in multithreading programs.

11. A paper to support bi-directional fences was voted in. This will support IBM's PowerPC architecture.

0 Comments Permalink

C++ Standard

Bottom Banner