From Jason Turner

[stmt.jump]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcspwcxby/{from.md → to.md} +40 -51
tmp/tmpcspwcxby/{from.md → to.md} RENAMED
@@ -1,7 +1,9 @@
1
  ## Jump statements <a id="stmt.jump">[[stmt.jump]]</a>
2
 
 
 
3
  Jump statements unconditionally transfer control.
4
 
5
  ``` bnf
6
  jump-statement:
7
  break ';'
@@ -9,43 +11,36 @@ jump-statement:
9
  return expr-or-braced-init-listₒₚₜ ';'
10
  coroutine-return-statement
11
  goto identifier ';'
12
  ```
13
 
14
- On exit from a scope (however accomplished), objects with automatic
15
- storage duration [[basic.stc.auto]] that have been constructed in that
16
- scope are destroyed in the reverse order of their construction.
17
-
18
- [*Note 1*: For temporaries, see  [[class.temporary]]. — *end note*]
19
-
20
- Transfer out of a loop, out of a block, or back past an initialized
21
- variable with automatic storage duration involves the destruction of
22
- objects with automatic storage duration that are in scope at the point
23
- transferred from but not at the point transferred to. (See  [[stmt.dcl]]
24
- for transfers into blocks).
25
-
26
- [*Note 2*: However, the program can be terminated (by calling
27
- `std::exit()` or `std::abort()` [[support.start.term]], for example)
28
- without destroying objects with automatic storage
29
- duration. — *end note*]
30
-
31
- [*Note 3*: A suspension of a coroutine [[expr.await]] is not considered
32
  to be an exit from a scope. — *end note*]
33
 
34
  ### The `break` statement <a id="stmt.break">[[stmt.break]]</a>
35
 
36
- The `break` statement shall occur only in an *iteration-statement* or a
37
- `switch` statement and causes termination of the smallest enclosing
38
- *iteration-statement* or `switch` statement; control passes to the
39
- statement following the terminated statement, if any.
 
40
 
41
  ### The `continue` statement <a id="stmt.cont">[[stmt.cont]]</a>
42
 
43
- The `continue` statement shall occur only in an *iteration-statement*
44
- and causes control to pass to the loop-continuation portion of the
45
- smallest enclosing *iteration-statement*, that is, to the end of the
46
- loop. More precisely, in each of the statements
 
47
 
48
  ``` cpp
49
  while (foo) {
50
  {
51
  // ...
@@ -81,39 +76,32 @@ A function returns to its caller by the `return` statement.
81
 
82
  The *expr-or-braced-init-list* of a `return` statement is called its
83
  operand. A `return` statement with no operand shall be used only in a
84
  function whose return type is cv `void`, a constructor [[class.ctor]],
85
  or a destructor [[class.dtor]]. A `return` statement with an operand of
86
- type `void` shall be used only in a function whose return type is
87
- cv `void`. A `return` statement with any other operand shall be used
88
- only in a function whose return type is not cv `void`; the `return`
89
- statement initializes the glvalue result or prvalue result object of the
90
- (explicit or implicit) function call by copy-initialization [[dcl.init]]
91
- from the operand.
92
 
93
- [*Note 1*: A `return` statement can involve an invocation of a
 
 
 
94
  constructor to perform a copy or move of the operand if it is not a
95
  prvalue or if its type differs from the return type of the function. A
96
- copy operation associated with a `return` statement may be elided or
97
  converted to a move operation if an automatic storage duration variable
98
  is returned [[class.copy.elision]]. — *end note*]
99
 
 
 
 
100
  [*Example 1*:
101
 
102
- ``` cpp
103
- std::pair<std::string,int> f(const char* p, int x) {
104
- return {p,x};
105
- }
106
- ```
107
-
108
- — *end example*]
109
-
110
- The destructor for the returned object is potentially invoked (
111
- [[class.dtor]], [[except.ctor]]).
112
-
113
- [*Example 2*:
114
-
115
  ``` cpp
116
  class A {
117
  ~A() {}
118
  };
119
  A f() { return A(); } // error: destructor of A is private (even though it is never invoked)
@@ -121,12 +109,12 @@ A f() { return A(); } // error: destructor of A is private (even though it is
121
 
122
  — *end example*]
123
 
124
  Flowing off the end of a constructor, a destructor, or a non-coroutine
125
  function with a cv `void` return type is equivalent to a `return` with
126
- no operand. Otherwise, flowing off the end of a function other than
127
- `main` [[basic.start.main]] or a coroutine [[dcl.fct.def.coroutine]]
128
  results in undefined behavior.
129
 
130
  The copy-initialization of the result of the call is sequenced before
131
  the destruction of temporaries at the end of the full-expression
132
  established by the operand of the `return` statement, which, in turn, is
@@ -165,12 +153,13 @@ where *`final-suspend`* is the exposition-only label defined in
165
  - Otherwise, *S* is the *compound-statement* `{` *expression*ₒₚₜ `;`
166
  *p*`.return_void()``; }`. The expression *p*`.return_void()` shall be
167
  a prvalue of type `void`.
168
 
169
  If *p*`.return_void()` is a valid expression, flowing off the end of a
170
- coroutine is equivalent to a `co_return` with no operand; otherwise
171
- flowing off the end of a coroutine results in undefined behavior.
 
172
 
173
  ### The `goto` statement <a id="stmt.goto">[[stmt.goto]]</a>
174
 
175
  The `goto` statement unconditionally transfers control to the statement
176
  labeled by the identifier. The identifier shall be a label
 
1
  ## Jump statements <a id="stmt.jump">[[stmt.jump]]</a>
2
 
3
+ ### General <a id="stmt.jump.general">[[stmt.jump.general]]</a>
4
+
5
  Jump statements unconditionally transfer control.
6
 
7
  ``` bnf
8
  jump-statement:
9
  break ';'
 
11
  return expr-or-braced-init-listₒₚₜ ';'
12
  coroutine-return-statement
13
  goto identifier ';'
14
  ```
15
 
16
+ [*Note 1*: On exit from a scope (however accomplished), objects with
17
+ automatic storage duration [[basic.stc.auto]] that have been constructed
18
+ in that scope are destroyed in the reverse order of their construction.
19
+ For temporaries, see  [[class.temporary]]. However, the program can be
20
+ terminated (by calling `std::exit()` or `std::abort()`
21
+ [[support.start.term]], for example) without destroying objects with
22
+ automatic storage duration. *end note*]
23
+
24
+ [*Note 2*: A suspension of a coroutine [[expr.await]] is not considered
 
 
 
 
 
 
 
 
 
25
  to be an exit from a scope. — *end note*]
26
 
27
  ### The `break` statement <a id="stmt.break">[[stmt.break]]</a>
28
 
29
+ A `break` statement shall be enclosed by [[stmt.pre]] an
30
+ *iteration-statement* [[stmt.iter]] or a `switch` statement
31
+ [[stmt.switch]]. The `break` statement causes termination of the
32
+ smallest such enclosing statement; control passes to the statement
33
+ following the terminated statement, if any.
34
 
35
  ### The `continue` statement <a id="stmt.cont">[[stmt.cont]]</a>
36
 
37
+ A `continue` statement shall be enclosed by [[stmt.pre]] an
38
+ *iteration-statement* [[stmt.iter]]. The `continue` statement causes
39
+ control to pass to the loop-continuation portion of the smallest such
40
+ enclosing statement, that is, to the end of the loop. More precisely, in
41
+ each of the statements
42
 
43
  ``` cpp
44
  while (foo) {
45
  {
46
  // ...
 
76
 
77
  The *expr-or-braced-init-list* of a `return` statement is called its
78
  operand. A `return` statement with no operand shall be used only in a
79
  function whose return type is cv `void`, a constructor [[class.ctor]],
80
  or a destructor [[class.dtor]]. A `return` statement with an operand of
81
+ type `void` shall be used only in a function that has a cv `void` return
82
+ type. A `return` statement with any other operand shall be used only in
83
+ a function that has a return type other than cv `void`; the `return`
84
+ statement initializes the returned reference or prvalue result object of
85
+ the (explicit or implicit) function call by copy-initialization
86
+ [[dcl.init]] from the operand.
87
 
88
+ [*Note 1*: A constructor or destructor does not have a return
89
+ type. — *end note*]
90
+
91
+ [*Note 2*: A `return` statement can involve an invocation of a
92
  constructor to perform a copy or move of the operand if it is not a
93
  prvalue or if its type differs from the return type of the function. A
94
+ copy operation associated with a `return` statement can be elided or
95
  converted to a move operation if an automatic storage duration variable
96
  is returned [[class.copy.elision]]. — *end note*]
97
 
98
+ The destructor for the result object is potentially invoked
99
+ [[class.dtor]], [[except.ctor]].
100
+
101
  [*Example 1*:
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ``` cpp
104
  class A {
105
  ~A() {}
106
  };
107
  A f() { return A(); } // error: destructor of A is private (even though it is never invoked)
 
109
 
110
  — *end example*]
111
 
112
  Flowing off the end of a constructor, a destructor, or a non-coroutine
113
  function with a cv `void` return type is equivalent to a `return` with
114
+ no operand. Otherwise, flowing off the end of a function that is neither
115
+ `main` [[basic.start.main]] nor a coroutine [[dcl.fct.def.coroutine]]
116
  results in undefined behavior.
117
 
118
  The copy-initialization of the result of the call is sequenced before
119
  the destruction of temporaries at the end of the full-expression
120
  established by the operand of the `return` statement, which, in turn, is
 
153
  - Otherwise, *S* is the *compound-statement* `{` *expression*ₒₚₜ `;`
154
  *p*`.return_void()``; }`. The expression *p*`.return_void()` shall be
155
  a prvalue of type `void`.
156
 
157
  If *p*`.return_void()` is a valid expression, flowing off the end of a
158
+ coroutine’s *function-body* is equivalent to a `co_return` with no
159
+ operand; otherwise flowing off the end of a coroutine’s *function-body*
160
+ results in undefined behavior.
161
 
162
  ### The `goto` statement <a id="stmt.goto">[[stmt.goto]]</a>
163
 
164
  The `goto` statement unconditionally transfers control to the statement
165
  labeled by the identifier. The identifier shall be a label