From Jason Turner

[basic.start]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjdh5fx2c/{from.md → to.md} +31 -35
tmp/tmpjdh5fx2c/{from.md → to.md} RENAMED
@@ -10,37 +10,33 @@ function. In a freestanding environment, start-up and termination is
10
  constructors for objects of namespace scope with static storage
11
  duration; termination contains the execution of destructors for objects
12
  with static storage duration.
13
 
14
  An implementation shall not predefine the `main` function. This function
15
- shall not be overloaded. It shall have a return type of type `int`, but
16
- otherwise its type is *implementation-defined*. All implementations
17
- shall allow both of the following definitions of `main`:
18
 
19
- ``` cpp
20
- int main() { /* ... */ }
21
- ```
22
 
23
- and
24
-
25
- ``` cpp
26
- int main(int argc, char* argv[]) { /* ... */ }
27
- ```
28
-
29
- In the latter form `argc` shall be the number of arguments passed to the
30
- program from the environment in which the program is run. If `argc` is
31
- nonzero these arguments shall be supplied in `argv[0]` through
32
- `argv[argc-1]` as pointers to the initial characters of null-terminated
33
- multibyte strings (NTMBS s) ([[multibyte.strings]]) and `argv[0]` shall
34
- be the pointer to the initial character of a NTMBSthat represents the
35
- name used to invoke the program or `""`. The value of `argc` shall be
36
- non-negative. The value of `argv[argc]` shall be 0. It is recommended
37
- that any further (optional) parameters be added after `argv`.
38
 
39
  The function `main` shall not be used within a program. The linkage (
40
  [[basic.link]]) of `main` is *implementation-defined*. A program that
41
- defines `main` as deleted or that declares `main` to be `inline,`
42
  `static`, or `constexpr` is ill-formed. The name `main` is not otherwise
43
  reserved. member functions, classes, and enumerations can be called
44
  `main`, as can entities in other namespaces.
45
 
46
  Terminating the program without leaving the current block (e.g., by
@@ -70,29 +66,29 @@ initiation. Non-local variables with thread storage duration are
70
  initialized as a consequence of thread execution. Within each of these
71
  phases of initiation, initialization occurs as follows.
72
 
73
  Variables with static storage duration ([[basic.stc.static]]) or thread
74
  storage duration ([[basic.stc.thread]]) shall be zero-initialized (
75
- [[dcl.init]]) before any other initialization takes place.
76
-
77
- *Constant initialization* is performed:
 
 
 
78
 
79
  - if each full-expression (including implicit conversions) that appears
80
  in the initializer of a reference with static or thread storage
81
  duration is a constant expression ([[expr.const]]) and the reference
82
  is bound to an lvalue designating an object with static storage
83
- duration or to a temporary (see  [[class.temporary]]);
84
  - if an object with static or thread storage duration is initialized by
85
- a constructor call, if the constructor is a `constexpr` constructor,
86
- if all constructor arguments are constant expressions (including
87
- conversions), and if, after function invocation substitution (
88
- [[dcl.constexpr]]), every constructor call and full-expression in the
89
- *mem-initializer*s and in the *brace-or-equal-initializer*s for
90
- non-static data members is a constant expression;
91
  - if an object with static or thread storage duration is not initialized
92
- by a constructor call and if every full-expression that appears in its
93
- initializer is a constant expression.
 
94
 
95
  Together, zero-initialization and constant initialization are called
96
  *static initialization*; all other initialization is *dynamic
97
  initialization*. Static initialization shall be performed before any
98
  dynamic initialization takes place. Dynamic initialization of a
@@ -150,11 +146,11 @@ double d1 = fd(); // may be initialized statically or dynamically to 1.0
150
  It is *implementation-defined* whether the dynamic initialization of a
151
  non-local variable with static storage duration is done before the first
152
  statement of `main`. If the initialization is deferred to some point in
153
  time after the first statement of `main`, it shall occur before the
154
  first odr-use ([[basic.def.odr]]) of any function or variable defined
155
- in the same translation unit as the variable to be initialized.[^10]
156
 
157
  ``` cpp
158
  // - File 1 -
159
  #include "a.h"
160
  #include "b.h"
 
10
  constructors for objects of namespace scope with static storage
11
  duration; termination contains the execution of destructors for objects
12
  with static storage duration.
13
 
14
  An implementation shall not predefine the `main` function. This function
15
+ shall not be overloaded. It shall have a declared return type of type
16
+ `int`, but otherwise its type is *implementation-defined*. An
17
+ implementation shall allow both
18
 
19
+ - a function of `()` returning `int` and
20
+ - a function of `(int`, pointer to pointer to `char)` returning `int`
 
21
 
22
+ as the type of `main` ([[dcl.fct]]). In the latter form, for purposes
23
+ of exposition, the first function parameter is called `argc` and the
24
+ second function parameter is called `argv`, where `argc` shall be the
25
+ number of arguments passed to the program from the environment in which
26
+ the program is run. If `argc` is nonzero these arguments shall be
27
+ supplied in `argv[0]` through `argv[argc-1]` as pointers to the initial
28
+ characters of null-terminated multibyte strings (NTMBS s) (
29
+ [[multibyte.strings]]) and `argv[0]` shall be the pointer to the initial
30
+ character of a NTMBSthat represents the name used to invoke the program
31
+ or `""`. The value of `argc` shall be non-negative. The value of
32
+ `argv[argc]` shall be 0. It is recommended that any further (optional)
33
+ parameters be added after `argv`.
 
 
 
34
 
35
  The function `main` shall not be used within a program. The linkage (
36
  [[basic.link]]) of `main` is *implementation-defined*. A program that
37
+ defines `main` as deleted or that declares `main` to be `inline`,
38
  `static`, or `constexpr` is ill-formed. The name `main` is not otherwise
39
  reserved. member functions, classes, and enumerations can be called
40
  `main`, as can entities in other namespaces.
41
 
42
  Terminating the program without leaving the current block (e.g., by
 
66
  initialized as a consequence of thread execution. Within each of these
67
  phases of initiation, initialization occurs as follows.
68
 
69
  Variables with static storage duration ([[basic.stc.static]]) or thread
70
  storage duration ([[basic.stc.thread]]) shall be zero-initialized (
71
+ [[dcl.init]]) before any other initialization takes place. A *constant
72
+ initializer* for an object `o` is an expression that is a constant
73
+ expression, except that it may also invoke `constexpr` constructors for
74
+ `o` and its subobjects even if those objects are of non-literal class
75
+ types such a class may have a non-trivial destructor . *Constant
76
+ initialization* is performed:
77
 
78
  - if each full-expression (including implicit conversions) that appears
79
  in the initializer of a reference with static or thread storage
80
  duration is a constant expression ([[expr.const]]) and the reference
81
  is bound to an lvalue designating an object with static storage
82
+ duration, to a temporary (see  [[class.temporary]]), or to a function;
83
  - if an object with static or thread storage duration is initialized by
84
+ a constructor call, and if the initialization full-expression is a
85
+ constant initializer for the object;
 
 
 
 
86
  - if an object with static or thread storage duration is not initialized
87
+ by a constructor call and if either the object is value-initialized or
88
+ every full-expression that appears in its initializer is a constant
89
+ expression.
90
 
91
  Together, zero-initialization and constant initialization are called
92
  *static initialization*; all other initialization is *dynamic
93
  initialization*. Static initialization shall be performed before any
94
  dynamic initialization takes place. Dynamic initialization of a
 
146
  It is *implementation-defined* whether the dynamic initialization of a
147
  non-local variable with static storage duration is done before the first
148
  statement of `main`. If the initialization is deferred to some point in
149
  time after the first statement of `main`, it shall occur before the
150
  first odr-use ([[basic.def.odr]]) of any function or variable defined
151
+ in the same translation unit as the variable to be initialized.[^11]
152
 
153
  ``` cpp
154
  // - File 1 -
155
  #include "a.h"
156
  #include "b.h"