Skip to content

Commit 0bc67d4

Browse files
authored
Merge pull request #868 from MicrosoftDocs/master
6/5 AM Publish
2 parents ee9fb77 + f2e3846 commit 0bc67d4

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

‎docs/cpp-conformance-improvements-2017.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,46 @@ D<int> d;
15751575

15761576
To fix the error, change the B() expression to B\<T>().
15771577

1578+
### constexpr aggregate initialization
1579+
1580+
Previous versions of the C++ compiler incorrectly handled constexpr aggregate initialization; it accepted invalid code in which the aggregate-init-list had too many elements, and produced bad codegen for it. The following code is an example of such code:
1581+
1582+
```cpp
1583+
#include <array>
1584+
struct X {
1585+
unsigned short a;
1586+
unsigned char b;
1587+
};
1588+
1589+
int main() {
1590+
constexpr std::array<X, 2> xs = {
1591+
{ 1, 2 },
1592+
{ 3, 4 }
1593+
};
1594+
return 0;
1595+
}
1596+
1597+
```
1598+
1599+
In Visual Studio 2017 version 15.7 update 3 and later, the previous example now raises *C2078 too many initializers*. The following example shows how to fix the code. When initializing a `std::array` with nested brace-init-lists, give the inner array a braced-list of its own:
1600+
1601+
```cpp
1602+
#include <array>
1603+
struct X {
1604+
unsigned short a;
1605+
unsigned char b;
1606+
};
1607+
1608+
int main() {
1609+
constexpr std::array<X, 2> xs = {{ // note double braces
1610+
{ 1, 2 },
1611+
{ 3, 4 }
1612+
}}; // note double braces
1613+
return 0;
1614+
}
1615+
1616+
```
1617+
15781618
## See also
15791619

15801620
[Visual C++ Language Conformance](visual-cpp-language-conformance.md)

‎docs/visual-cpp-in-visual-studio.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ You can use the vcpkg command-line tool to greatly simplify the discovery and in
130130
[Standard C++](http://isocpp.org/)<br/>
131131
Learn about C++, get an overview of Modern C++, and find links to books, articles, talks, and events
132132

133-
[Learn Visual C++](http://msdn.microsoft.com/vstudio/hh386302.aspx)<br/>
133+
[Learn Visual C++](build/vscpp-step-1-create.md)<br/>
134134
Start learning C++.
135135

136136
## See also

0 commit comments

Comments
 (0)