Skip to content

Commit 424818d

Browse files
author
Colin Robertson
committed
Fix C5039 to address 1619
1 parent fd1a003 commit 424818d

File tree

1 file changed

+10
-5
lines changed
  • docs/error-messages/compiler-warnings

1 file changed

+10
-5
lines changed

docs/error-messages/compiler-warnings/c5038.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
---
22
title: "Compiler Warning C5038"
3-
ms.date: "02/16/2018"
3+
description: Describes the causes and fixes for compiler warning C5038.
4+
ms.date: "10/11/2019"
45
helpviewer_keywords: ["C5038"]
56
---
67
# Compiler Warning C5038
78

8-
> data member '*member1*' will be initialized after data member '*member2*'
9+
> data member '*member1*' will be initialized after data member '*member2*'\
910
> data member '*member*' will be initialized after base class '*base_class*'
1011
11-
Class members are initialized in the order they are declared, not the order they appear in initializer lists. This warning indicates that the order of initialization is not the same as the declaration order of data members or base classes. This can lead to undefined runtime behavior if the initialization of one member in the list depends on the initialization of a member that is declared later.
12+
## Remarks
13+
14+
Class members are initialized in the order they're declared, not the order they appear in initializer lists. This warning indicates the order of initialization isn't the same as the declaration order of data members or base classes. This order can lead to undefined runtime behavior, if the initialization of one member in the list depends on the initialization of a member that's declared later.
1215

1316
This warning is new in Visual Studio 2017 version 15.3, and is off by default. Use [/Wall](../../build/reference/compiler-option-warning-level.md) to enable all warnings that are off by default, or __/w__*n*__5038__ to enable C5038 as a level *n* warning. For more information, see [Compiler Warnings That Are Off By Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md). For information on how to disable warnings by compiler version, see [Compiler warnings by compiler version](compiler-warnings-by-compiler-version.md).
1417

1518
## Example
1619

17-
In the following example, Visual Studio 2017 version 15.3 (with /Wall) raises "warning C5038: data member 'A::y' will be initialized after data member 'A::x'":
20+
In the following example, Visual Studio (using /Wall) raises "warning C5038: data member 'A::y' will be initialized after data member 'A::x'":
1821

1922
```cpp
23+
// C5038.cpp
24+
// Compile using: cl /EHsc /c /w15038 C5038.cpp
2025
struct A
2126
{
22-
A(int a) : y(a), x(y) {} // C5938 Initialized in reverse, y reused
27+
A(int a) : y(a), x(y) {} // C5038, Initialized in reverse, y reused
2328
int x;
2429
int y;
2530
};

0 commit comments

Comments
 (0)