From Jason Turner

[stmt.jump]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp13pyga_n/{from.md → to.md} +44 -30
tmp/tmp13pyga_n/{from.md → to.md} RENAMED
@@ -4,26 +4,30 @@ Jump statements unconditionally transfer control.
4
 
5
  ``` bnf
6
  jump-statement:
7
  'break ;'
8
  'continue ;'
9
- 'return' expressionₒₚₜ ';'
10
- 'return' braced-init-list ';'
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
16
- that scope are destroyed in the reverse order of their construction. For
17
- temporaries, see  [[class.temporary]]. Transfer out of a loop, out of a
18
- block, or back past an initialized variable with automatic storage
19
- duration involves the destruction of objects with automatic storage
20
- duration that are in scope at the point transferred from but not at the
21
- point transferred to. (See  [[stmt.dcl]] for transfers into blocks).
22
- However, the program can be terminated (by calling `std::exit()` or
23
- `std::abort()` ([[support.start.term]]), for example) without
24
- destroying class objects with automatic storage duration.
 
 
 
 
 
25
 
26
  ### The `break` statement <a id="stmt.break">[[stmt.break]]</a>
27
 
28
  The `break` statement shall occur only in an *iteration-statement* or a
29
  `switch` statement and causes termination of the smallest enclosing
@@ -69,38 +73,48 @@ equivalent to `goto` `contin`.
69
 
70
  ### The `return` statement <a id="stmt.return">[[stmt.return]]</a>
71
 
72
  A function returns to its caller by the `return` statement.
73
 
74
- A return statement with neither an *expression* nor a *braced-init-list*
75
- can be used only in functions that do not return a value, that is, a
76
- function with the return type cv `void`, a constructor (
77
  [[class.ctor]]), or a destructor ([[class.dtor]]). A return statement
78
- with an expression of non-void type can be used only in functions
79
- returning a value; the value of the expression is returned to the caller
80
- of the function. The value of the expression is implicitly converted to
81
- the return type of the function in which it appears. A return statement
82
- can involve the construction and copy or move of a temporary object (
83
- [[class.temporary]]). A copy or move operation associated with a return
84
- statement may be elided or considered as an rvalue for the purpose of
85
- overload resolution in selecting a constructor ([[class.copy]]). A
86
- return statement with a *braced-init-list* initializes the object or
87
- reference to be returned from the function by copy-list-initialization (
88
- [[dcl.init.list]]) from the specified initializer list.
 
 
 
 
89
 
90
  ``` cpp
91
  std::pair<std::string,int> f(const char* p, int x) {
92
  return {p,x};
93
  }
94
  ```
95
 
96
- Flowing off the end of a function is equivalent to a `return` with no
97
- value; this results in undefined behavior in a value-returning function.
98
 
99
- A return statement with an expression of type `void` can be used only in
100
- functions with a return type of *cv* `void`; the expression is evaluated
101
- just before the function returns to its caller.
 
 
 
 
 
 
 
102
 
103
  ### The `goto` statement <a id="stmt.goto">[[stmt.goto]]</a>
104
 
105
  The `goto` statement unconditionally transfers control to the statement
106
  labeled by the identifier. The identifier shall be a label (
 
4
 
5
  ``` bnf
6
  jump-statement:
7
  'break ;'
8
  'continue ;'
9
+ 'return' expr-or-braced-init-listₒₚₜ ';'
 
10
  'goto' identifier ';'
11
  ```
12
 
13
  On exit from a scope (however accomplished), objects with automatic
14
  storage duration ([[basic.stc.auto]]) that have been constructed in
15
+ that scope are destroyed in the reverse order of their construction.
16
+
17
+ [*Note 1*: For temporaries, see  [[class.temporary]]. *end note*]
18
+
19
+ Transfer out of a loop, out of a block, or back past an initialized
20
+ variable with automatic storage duration involves the destruction of
21
+ objects with automatic storage duration that are in scope at the point
22
+ transferred from but not at the point transferred to. (See  [[stmt.dcl]]
23
+ for transfers into blocks).
24
+
25
+ [*Note 2*: However, the program can be terminated (by calling
26
+ `std::exit()` or `std::abort()` ([[support.start.term]]), for example)
27
+ without destroying class objects with automatic storage
28
+ duration. — *end note*]
29
 
30
  ### The `break` statement <a id="stmt.break">[[stmt.break]]</a>
31
 
32
  The `break` statement shall occur only in an *iteration-statement* or a
33
  `switch` statement and causes termination of the smallest enclosing
 
73
 
74
  ### The `return` statement <a id="stmt.return">[[stmt.return]]</a>
75
 
76
  A function returns to its caller by the `return` statement.
77
 
78
+ The *expr-or-braced-init-list* of a return statement is called its
79
+ operand. A return statement with no operand shall be used only in a
80
+ function whose return type is cv `void`, a constructor (
81
  [[class.ctor]]), or a destructor ([[class.dtor]]). A return statement
82
+ with an operand of type `void` shall be used only in a function whose
83
+ return type is cv `void`. A return statement with any other operand
84
+ shall be used only in a function whose return type is not cv `void`; the
85
+ return statement initializes the glvalue result or prvalue result object
86
+ of the (explicit or implicit) function call by copy-initialization (
87
+ [[dcl.init]]) from the operand.
88
+
89
+ [*Note 1*: A return statement can involve an invocation of a
90
+ constructor to perform a copy or move of the operand if it is not a
91
+ prvalue or if its type differs from the return type of the function. A
92
+ copy operation associated with a return statement may be elided or
93
+ converted to a move operation if an automatic storage duration variable
94
+ is returned ([[class.copy]]). — *end note*]
95
+
96
+ [*Example 1*:
97
 
98
  ``` cpp
99
  std::pair<std::string,int> f(const char* p, int x) {
100
  return {p,x};
101
  }
102
  ```
103
 
104
+ *end example*]
 
105
 
106
+ Flowing off the end of a constructor, a destructor, or a function with a
107
+ cv `void` return type is equivalent to a `return` with no operand.
108
+ Otherwise, flowing off the end of a function other than `main` (
109
+ [[basic.start.main]]) results in undefined behavior.
110
+
111
+ The copy-initialization of the result of the call is sequenced before
112
+ the destruction of temporaries at the end of the full-expression
113
+ established by the operand of the return statement, which, in turn, is
114
+ sequenced before the destruction of local variables ([[stmt.jump]]) of
115
+ the block enclosing the return statement.
116
 
117
  ### The `goto` statement <a id="stmt.goto">[[stmt.goto]]</a>
118
 
119
  The `goto` statement unconditionally transfers control to the statement
120
  labeled by the identifier. The identifier shall be a label (