From Jason Turner

[diff.cpp11]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbgmmccci/{from.md → to.md} +67 -5
tmp/tmpbgmmccci/{from.md → to.md} RENAMED
@@ -15,33 +15,67 @@ International Standard, but the macro invocation produces different
15
  outcomes because the single quotes delimit a character literal in C++11,
16
  whereas they are digit separators in this International Standard:
17
 
18
  ``` cpp
19
  #define M(x, ...) __VA_ARGS__
20
- int x[2] = { M(1'2,3'4) };
21
- // int x[2] = {\ \ \ \ \ } --- C++11
22
- // int x[2] = { 3'4 } --- this International Standard
23
  ```
24
 
25
  ### Clause [[basic]]: basic concepts <a id="diff.cpp11.basic">[[diff.cpp11.basic]]</a>
26
 
27
  [[basic.stc.dynamic.deallocation]] **Change:** New usual (non-placement)
28
- deallocator **Rationale:** Required for sized deallocation. **Effect on
29
  original feature:** Valid C++11code could declare a global placement
30
  allocation function and deallocation function as follows:
31
 
32
  ``` cpp
33
- void operator new(std::size_t, std::size_t);
34
  void operator delete(void*, std::size_t) noexcept;
35
  ```
36
 
37
  In this International Standard, however, the declaration of
38
  `operator delete` might match a predefined usual (non-placement)
39
  `operator delete` ([[basic.stc.dynamic]]). If so, the program is
40
  ill-formed, as it was for class member allocation functions and
41
  deallocation functions ([[expr.new]]).
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ### Clause [[dcl.dcl]]: declarations <a id="diff.cpp11.dcl.dcl">[[diff.cpp11.dcl.dcl]]</a>
44
 
45
  [[dcl.constexpr]] **Change:** `constexpr` non-static member functions
46
  are not implicitly `const` member functions. **Rationale:** Necessary to
47
  allow `constexpr` member functions to mutate the object. **Effect on
@@ -55,10 +89,38 @@ struct S {
55
  constexpr const int &f();
56
  int &f();
57
  };
58
  ```
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  ### Clause [[input.output]]: input/output library <a id="diff.cpp11.input.output">[[diff.cpp11.input.output]]</a>
61
 
62
  [[c.files]] **Change:** `gets` is not defined. **Rationale:** Use of
63
  `gets` is considered dangerous. **Effect on original feature:** Valid
64
  C++11code that uses the `gets` function may fail to compile in this
 
15
  outcomes because the single quotes delimit a character literal in C++11,
16
  whereas they are digit separators in this International Standard:
17
 
18
  ``` cpp
19
  #define M(x, ...) __VA_ARGS__
20
+ int x[2] = { M(1'2,3'4, 5) };
21
+ // int x[2] = { 5 \ \ \ \ \ } --- C++11
22
+ // int x[2] = { 3'4, 5 } --- this International Standard
23
  ```
24
 
25
  ### Clause [[basic]]: basic concepts <a id="diff.cpp11.basic">[[diff.cpp11.basic]]</a>
26
 
27
  [[basic.stc.dynamic.deallocation]] **Change:** New usual (non-placement)
28
+ deallocator. **Rationale:** Required for sized deallocation. **Effect on
29
  original feature:** Valid C++11code could declare a global placement
30
  allocation function and deallocation function as follows:
31
 
32
  ``` cpp
33
+ void* operator new(std::size_t, std::size_t);
34
  void operator delete(void*, std::size_t) noexcept;
35
  ```
36
 
37
  In this International Standard, however, the declaration of
38
  `operator delete` might match a predefined usual (non-placement)
39
  `operator delete` ([[basic.stc.dynamic]]). If so, the program is
40
  ill-formed, as it was for class member allocation functions and
41
  deallocation functions ([[expr.new]]).
42
 
43
+ ### Clause [[expr]]: expressions <a id="diff.cpp11.expr">[[diff.cpp11.expr]]</a>
44
+
45
+ [[expr.cond]] **Change:** A conditional expression with a throw
46
+ expression as its second or third operand keeps the type and value
47
+ category of the other operand. **Rationale:** Formerly mandated
48
+ conversions (lvalue-to-rvalue ([[conv.lval]]), array-to-pointer (
49
+ [[conv.array]]), and function-to-pointer ([[conv.func]]) standard
50
+ conversions), especially the creation of the temporary due to
51
+ lvalue-to-rvalue conversion, were considered gratuitous and surprising.
52
+ **Effect on original feature:** Valid C++11code that relies on the
53
+ conversions may behave differently in this International Standard:
54
+
55
+ ``` cpp
56
+ struct S {
57
+ int x = 1;
58
+ void mf() { x = 2; }
59
+ };
60
+ int f(bool cond) {
61
+ S s;
62
+ (cond ? s : throw 0).mf();
63
+ return s.x;
64
+ }
65
+ ```
66
+
67
+ In C++11, `f(true)` returns `1`. In this International Standard, it
68
+ returns `2`.
69
+
70
+ ``` cpp
71
+ sizeof(true ? "" : throw 0)
72
+ ```
73
+
74
+ In C++11, the expression yields `sizeof(const char*)`. In this
75
+ International Standard, it yields `sizeof(const char[1])`.
76
+
77
  ### Clause [[dcl.dcl]]: declarations <a id="diff.cpp11.dcl.dcl">[[diff.cpp11.dcl.dcl]]</a>
78
 
79
  [[dcl.constexpr]] **Change:** `constexpr` non-static member functions
80
  are not implicitly `const` member functions. **Rationale:** Necessary to
81
  allow `constexpr` member functions to mutate the object. **Effect on
 
89
  constexpr const int &f();
90
  int &f();
91
  };
92
  ```
93
 
94
+ ### Clause [[dcl.decl]]: declarators <a id="diff.cpp11.dcl.decl">[[diff.cpp11.dcl.decl]]</a>
95
+
96
+ [[dcl.init.aggr]] **Change:** Classes with default member initializers
97
+ can be aggregates. **Rationale:** Necessary to allow default member
98
+ initializers to be used by aggregate initialization. **Effect on
99
+ original feature:** Valid C++11code may fail to compile or may change
100
+ meaning in this International Standard.
101
+
102
+ ``` cpp
103
+ struct S { // Aggregate in C++14onwards.
104
+ int m = 1;
105
+ };
106
+ struct X {
107
+ operator int();
108
+ operator S();
109
+ };
110
+ X a{};
111
+ S b{a}; // uses copy constructor in C++11,
112
+ // performs aggregate initialization in this International Standard
113
+ ```
114
+
115
+ ### Clause [[library]]: library introduction <a id="diff.cpp11.library">[[diff.cpp11.library]]</a>
116
+
117
+ [[headers]] **Change:** New header. **Rationale:** New functionality.
118
+ **Effect on original feature:** The C++header `<shared_mutex>` is new.
119
+ Valid C++11code that `#include`s a header with that name may be invalid
120
+ in this International Standard.
121
+
122
  ### Clause [[input.output]]: input/output library <a id="diff.cpp11.input.output">[[diff.cpp11.input.output]]</a>
123
 
124
  [[c.files]] **Change:** `gets` is not defined. **Rationale:** Use of
125
  `gets` is considered dangerous. **Effect on original feature:** Valid
126
  C++11code that uses the `gets` function may fail to compile in this