|
3772 | 3772 | Banana &&banana3 = Alaska(); // ill-formed
|
3773 | 3773 | }
|
3774 | 3774 |
|
3775 |
| -const double& rcd2 = 2; // \tcode{rcd2} refers to temporary with value \tcode{2.0} |
3776 |
| -double&& rrd = 2; // \tcode{rrd} refers to temporary with value \tcode{2.0} |
| 3775 | +const double& rcd2 = 2; // \tcode{rcd2} refers to temporary with value \tcode{2.0} |
| 3776 | +double&& rrd = 2; // \tcode{rrd} refers to temporary with value \tcode{2.0} |
3777 | 3777 | const volatile int cvi = 1;
|
3778 |
| -const int& r2 = cvi; // error: cv-qualifier dropped |
| 3778 | +const int& r2 = cvi; // error: cv-qualifier dropped |
3779 | 3779 | struct A { operator volatile int&(); } a;
|
3780 |
| -const int& r3 = a; // error: cv-qualifier dropped |
3781 |
| - // from result of conversion function |
| 3780 | +const int& r3 = a; // error: cv-qualifier dropped |
| 3781 | + // from result of conversion function |
3782 | 3782 | double d2 = 1.0;
|
3783 |
| -double&& rrd2 = d2; // error: initializer is lvalue of related type |
| 3783 | +double&& rrd2 = d2; // error: initializer is lvalue of related type |
3784 | 3784 | struct X { operator int&(); };
|
3785 |
| -int&& rri2 = X(); // error: result of conversion function is lvalue of related type |
| 3785 | +int&& rri2 = X(); // error: result of conversion function is lvalue of related type |
3786 | 3786 | int i3 = 2;
|
3787 |
| -double&& rrd3 = i3; // \tcode{rrd3} refers to temporary with value \tcode{2.0} |
| 3787 | +double&& rrd3 = i3; // \tcode{rrd3} refers to temporary with value \tcode{2.0} |
3788 | 3788 | \end{codeblock}
|
3789 | 3789 | \end{example}
|
3790 | 3790 | \end{itemize}
|
|
3880 | 3880 | \begin{example}
|
3881 | 3881 | \begin{codeblock}
|
3882 | 3882 | struct A { int x; int y; int z; };
|
3883 |
| -A a{.y = 2, .x = 1}; // error: designator order does not match declaration order |
3884 |
| -A b{.x = 1, .z = 2}; // OK, \tcode{b.y} initialized to \tcode{0} |
| 3883 | +A a{.y = 2, .x = 1}; // error: designator order does not match declaration order |
| 3884 | +A b{.x = 1, .z = 2}; // OK, \tcode{b.y} initialized to \tcode{0} |
3885 | 3885 | \end{codeblock}
|
3886 | 3886 | \end{example}
|
3887 | 3887 |
|
|
4126 | 4126 |
|
4127 | 4127 | struct A {
|
4128 | 4128 | std::initializer_list<int> i4;
|
4129 |
| - A() : i4{ 1, 2, 3 } {} // ill-formed, would create a dangling reference |
| 4129 | + A() : i4{ 1, 2, 3 } {} // ill-formed, would create a dangling reference |
4130 | 4130 | };
|
4131 | 4131 | \end{codeblock}
|
4132 | 4132 |
|
|
4172 | 4172 | list-initializations.\end{note} \begin{example}
|
4173 | 4173 |
|
4174 | 4174 | \begin{codeblock}
|
4175 |
| -int x = 999; // \tcode{x} is not a constant expression |
| 4175 | +int x = 999; // \tcode{x} is not a constant expression |
4176 | 4176 | const int y = 999;
|
4177 | 4177 | const int z = 99;
|
4178 |
| -char c1 = x; // OK, though it might narrow (in this case, it does narrow) |
4179 |
| -char c2{x}; // error: might narrow |
4180 |
| -char c3{y}; // error: narrows (assuming \tcode{char} is 8 bits) |
4181 |
| -char c4{z}; // OK: no narrowing needed |
4182 |
| -unsigned char uc1 = {5}; // OK: no narrowing needed |
4183 |
| -unsigned char uc2 = {-1}; // error: narrows |
4184 |
| -unsigned int ui1 = {-1}; // error: narrows |
| 4178 | +char c1 = x; // OK, though it might narrow (in this case, it does narrow) |
| 4179 | +char c2{x}; // error: might narrow |
| 4180 | +char c3{y}; // error: narrows (assuming \tcode{char} is 8 bits) |
| 4181 | +char c4{z}; // OK: no narrowing needed |
| 4182 | +unsigned char uc1 = {5}; // OK: no narrowing needed |
| 4183 | +unsigned char uc2 = {-1}; // error: narrows |
| 4184 | +unsigned int ui1 = {-1}; // error: narrows |
4185 | 4185 | signed int si1 =
|
4186 |
| - { (unsigned int)-1 }; // error: narrows |
4187 |
| -int ii = {2.0}; // error: narrows |
4188 |
| -float f1 { x }; // error: might narrow |
4189 |
| -float f2 { 7 }; // OK: 7 can be exactly represented as a \tcode{float} |
| 4186 | + { (unsigned int)-1 }; // error: narrows |
| 4187 | +int ii = {2.0}; // error: narrows |
| 4188 | +float f1 { x }; // error: might narrow |
| 4189 | +float f2 { 7 }; // OK: 7 can be exactly represented as a \tcode{float} |
4190 | 4190 | int f(int);
|
4191 |
| -int a[] = |
4192 |
| - { 2, f(2), f(2.0) }; // OK: the \tcode{double}-to-\tcode{int} conversion is not at the top level |
| 4191 | +int a[] = { 2, f(2), f(2.0) }; // OK: the \tcode{double}-to-\tcode{int} conversion is not at the top level |
4193 | 4192 | \end{codeblock}
|
4194 | 4193 | \end{example}%
|
4195 | 4194 | \indextext{initialization!list-initialization|)}%
|
|
0 commit comments