tmp/tmpqc9q5m16/{from.md → to.md}
RENAMED
|
@@ -1,19 +1,44 @@
|
|
| 1 |
-
### [[dcl
|
| 2 |
|
| 3 |
**Change:** Remove `auto` as a storage class specifier. **Rationale:**
|
| 4 |
New feature. **Effect on original feature:** Valid C++03 code that uses
|
| 5 |
the keyword `auto` as a storage class specifier may be invalid in this
|
| 6 |
revision of C++. In this revision of C++, `auto` indicates that the type
|
| 7 |
of a variable is to be deduced from its initializer expression.
|
| 8 |
|
| 9 |
**Change:** Narrowing restrictions in aggregate initializers.
|
| 10 |
**Rationale:** Catches bugs. **Effect on original feature:** Valid C++03
|
| 11 |
-
code may fail to compile in this revision of C++.
|
|
|
|
|
|
|
| 12 |
|
| 13 |
``` cpp
|
| 14 |
int x[] = { 2.0 };
|
| 15 |
```
|
| 16 |
|
| 17 |
This code is valid in C++03 but invalid in this revision of C++ because
|
| 18 |
`double` to `int` is a narrowing conversion.
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### [[dcl]]: declarations <a id="diff.cpp03.dcl.dcl">[[diff.cpp03.dcl.dcl]]</a>
|
| 2 |
|
| 3 |
**Change:** Remove `auto` as a storage class specifier. **Rationale:**
|
| 4 |
New feature. **Effect on original feature:** Valid C++03 code that uses
|
| 5 |
the keyword `auto` as a storage class specifier may be invalid in this
|
| 6 |
revision of C++. In this revision of C++, `auto` indicates that the type
|
| 7 |
of a variable is to be deduced from its initializer expression.
|
| 8 |
|
| 9 |
**Change:** Narrowing restrictions in aggregate initializers.
|
| 10 |
**Rationale:** Catches bugs. **Effect on original feature:** Valid C++03
|
| 11 |
+
code may fail to compile in this revision of C++.
|
| 12 |
+
|
| 13 |
+
[*Example 1*:
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
int x[] = { 2.0 };
|
| 17 |
```
|
| 18 |
|
| 19 |
This code is valid in C++03 but invalid in this revision of C++ because
|
| 20 |
`double` to `int` is a narrowing conversion.
|
| 21 |
|
| 22 |
+
— *end example*]
|
| 23 |
+
|
| 24 |
+
**Change:** Names declared in an anonymous namespace changed from
|
| 25 |
+
external linkage to internal linkage; language linkage applies to names
|
| 26 |
+
with external linkage only. **Rationale:** Alignment with user
|
| 27 |
+
expectations. **Effect on original feature:** Valid C++03 code may
|
| 28 |
+
violate the one-definition rule [[basic.def.odr]] in this revision of
|
| 29 |
+
C++.
|
| 30 |
+
|
| 31 |
+
[*Example 2*:
|
| 32 |
+
|
| 33 |
+
``` cpp
|
| 34 |
+
namespace { extern "C" { extern int x; } } // #1, previously external linkage and C language linkage,
|
| 35 |
+
// now internal linkage and C++{} language linkage
|
| 36 |
+
namespace A { extern "C" int x = 42; } // #2, external linkage and C language linkage
|
| 37 |
+
int main(void) { return x; }
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
This code is valid in C++03, but `#2` is not a definition for `#1` in
|
| 41 |
+
this revision of C++, violating the one-definition rule.
|
| 42 |
+
|
| 43 |
+
— *end example*]
|
| 44 |
+
|