Skip to content

Repo sync for protected branch #5157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions docs/error-messages/compiler-warnings/compiler-warning-c4430.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
---
description: "Learn more about: Compiler Warning C4430"
title: "Compiler Warning C4430"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1, error) C4430"
title: "Compiler warning (level 1, error) C4430"
ms.date: "1/25/2025"
f1_keywords: ["C4430"]
helpviewer_keywords: ["C4430"]
ms.assetid: 12efbfff-aa58-4a86-a7d6-2c6a12d01dd3
---
# Compiler Warning C4430
# Compiler Warning (level 1, Error) C4430

missing type specifier - int assumed. Note: C++ does not support default-int
> missing type specifier - int assumed. Note: C++ does not support default-int
This error can be generated as a result of compiler conformance work that was done for Visual Studio 2005: all declarations must explicitly specify the type; int is no longer assumed.
This error might be generated due to compiler conformance work done for Visual Studio 2005: all declarations must explicitly specify the type; `int` is no longer assumed.

C4430 is always issued as an error. You can turn off this warning with the `#pragma warning` or **/wd**; see [warning](../../preprocessor/warning.md) or [/w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level)](../../build/reference/compiler-option-warning-level.md) for more information.
C4430 is always issued as an error. You can turn off this warning with the `#pragma warning` or `/wd`. For more information, see [`warning`](../../preprocessor/warning.md) or [`/w`, `/W0`, `/W1`, `/W2`, `/W3`, `/W4`, `/w1`, `/w2`, `/w3`, `/w4`, `/Wall`, `/wd`, `/we`, `/wo`, `/Wv`, `/WX` (Warning Level)](../../build/reference/compiler-option-warning-level.md).

## Example

The following sample generates C4430.
The following sample generates C4430:

```cpp
// C4430.cpp
// compile with: /c
struct CMyClass {
CUndeclared m_myClass; // C4430
int m_myClass; // OK
int m_myClass;
};

typedef struct {
POINT(); // C4430
// try the following line instead
// int POINT();
someFunction(); // C4430
unsigned x;
unsigned y;
} POINT;
```
The following addresses C4430:
```cpp
// compile with: /c
#include "CUndeclared.h" // for `CUndeclared`
struct CMyClass {
CUndeclared m_myClass;
int m_myClass;
};
typedef struct {
int someFunction();
unsigned x;
unsigned y;
} POINT;
```
15 changes: 7 additions & 8 deletions docs/error-messages/compiler-warnings/compiler-warning-c4439.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
description: "Learn more about: Compiler Warning C4439"
title: "Compiler Warning C4439"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1, error) C4439"
title: "Compiler warning (level 1, error) C4439"
ms.date: "1/22/2025"
f1_keywords: ["C4439"]
helpviewer_keywords: ["C4439"]
ms.assetid: 9449958f-f407-4824-829b-9e092f2af97d
---
# Compiler Warning C4439
# Compiler warning C4439

'function' : function definition with a managed type in the signature must have a __clrcall calling convention
> '*function name*': function definition with a managed type in the signature must have a `__clrcall` calling convention

The compiler implicitly replaced a calling convention with [`__clrcall`](../../cpp/clrcall.md). To resolve this warning, remove the **`__cdecl`** or **`__stdcall`** calling convention.

C4439 is always issued as an error. You can turn off this warning with the `#pragma warning` or **`/wd`**; see [warning](../../preprocessor/warning.md) or [/w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level)](../../build/reference/compiler-option-warning-level.md) for more information.
C4439 is always issued as an error. You can turn off this warning with the `#pragma warning` or **`/wd`**. For more information, see [`warning`](../../preprocessor/warning.md) or [`/w`, `/W0`, `/W1`, `/W2`, `/W3`, `/W4`, `/w1`, `/w2`, `/w3`, `/w4`, `/Wall`, `/wd`, `/we`, `/wo`, `/Wv`, `/WX` (Warning Level)](../../build/reference/compiler-option-warning-level.md).

## Example

The following sample generates C4439.
The following sample generates C4439:

```cpp
// C4439.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
---
description: "Learn more about: Compiler Warning (level 1) C4436"
title: "Compiler Warning (level 1) C4436"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1 and level 4) C4436"
title: "Compiler warning (level 1 and level 4) C4436"
ms.date: "1/22/2025"
f1_keywords: ["C4436"]
helpviewer_keywords: ["C4436"]
ms.assetid: 2b54a1fc-c9c6-4cc9-90be-faa44fc715d5
---
# Compiler Warning (level 1) C4436
# Compiler warning (level 1) C4436

dynamic_cast from virtual base 'class1' to 'class2' in constructor or destructor could fail with partially-constructed object Compile with /vd2 or define 'class2' with #pragma vtordisp(2) in effect
> `dynamic_cast` from virtual base '*base_class*' to '*derived_class*' in constructor or destructor could fail with partially-constructed object

The compiler has encountered a **`dynamic_cast`** operation with the following characteristics.
A `dynamic_cast` operation is used when:

- The cast is from a base class pointer to a derived class pointer.

- The derived class virtually inherits the base class.
- The derived class doesn't have a `vtordisp` field for the virtual base.
- The cast is found in a constructor or destructor of the derived class, or a class that inherits from the derived class.

- The derived class does not have a `vtordisp` field for the virtual base.

- The cast is found in a constructor or destructor of the derived class, or some class which further inherits from the derived class.

The warning indicates the **`dynamic_cast`** might not perform correctly, if it is operating on a partially-constructed object. That happens if the derived constructor/destructor is operating on a sub-object of some further derived object. If the derived class named in the warning is never further derived, the warning can be ignored.
This warning indicates that the `dynamic_cast` might not perform correctly if it is applied to a partially constructed object. Which happens if the derived constructor/destructor is operating on a subobject of some further derived object. If the derived class named in the warning isn't further derived, you can ignore the warning.

## Example

The following sample generates C4436 and demonstrates the code generation issue that arises from the missing `vtordisp` field.
The following sample generates C4436 and demonstrates the code generation issue due to the missing `vtordisp` field:

```cpp
// C4436.cpp
// To see the warning and runtime assert, compile with: /W1
// To eliminate the warning and assert, compile with: /W1 /vd2
// To eliminate the warning and assert, compile with: /W1 /vd2
// or compile with: /W1 /DFIX
#include <cassert>

Expand All @@ -48,7 +44,7 @@ struct B : virtual A
{
A* a = static_cast<A*>(this);
B* b = dynamic_cast<B*>(a); // C4436
assert(this == b); // assert unless compiled with /vd2
assert(this == b); // asserts unless compiled with /vd2
}
};
#if defined(FIX)
Expand All @@ -68,6 +64,6 @@ int main()

## See also

[dynamic_cast Operator](../../cpp/dynamic-cast-operator.md)<br/>
[vtordisp](../../preprocessor/vtordisp.md)<br/>
[Compiler Warning (level 4) C4437](../../error-messages/compiler-warnings/compiler-warning-level-4-c4437.md)
[`dynamic_cast` Operator](../../cpp/dynamic-cast-operator.md)\
[`vtordisp`](../../preprocessor/vtordisp.md)\
[Compiler Warning (level 1 and level 4, off) C4437](compiler-warning-level-4-c4437.md)
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
---
description: "Learn more about: Compiler Warning (level 2) C4412"
title: "Compiler Warning (level 2) C4412"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 2, off) C4412"
title: "Compiler warning (level 2, off) C4412"
ms.date: "1/22/2025"
f1_keywords: ["C4412"]
helpviewer_keywords: ["C4412"]
ms.assetid: f28dc531-1a98-497b-a366-0a13e1bc81c7
---
# Compiler Warning (level 2) C4412
# Compiler warning (level 2, off) C4412

> '*function*' : function signature contains type '*type*'; C++ objects are unsafe to pass between pure code and mixed or native.
> '*function*': function signature contains type '*type*'; C++ objects are unsafe to pass between pure code and mixed or native.

## Remarks

The **/clr:pure** compiler option is deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017. If you have code that needs to be pure, we recommend that you port it to C#.
The `/clr:pure` compiler option is deprecated in Visual Studio 2015, and unsupported starting in Visual Studio 2017. If you have code that needs to be CLR pure, we recommend that you port it to C#.

The compiler detected a potentially unsafe situation that could result in a runtime error: a call is being made from a **/clr:pure** compiland to a function that was imported via dllimport and the function signature contains an unsafe type. A type is unsafe if it contains a member function or has a data member that is an unsafe type or an indirection to an unsafe type.
The compiler detected a potentially unsafe situation that could result in a runtime error: a call is being made from code compiled with `/clr:pure` to a function imported via `dllimport`, and the function signature contains an unsafe type. A type is unsafe if it contains a member function or has a data member that is an unsafe type or an indirection to an unsafe type.

This is unsafe because of the difference in the default calling conventions between pure and native code (or mixed native and managed). When importing (via `dllimport`) a function into a **/clr:pure** compiland, ensure that the declarations of each type in the signature are identical to those in the compiland that exports the function (being especially careful about differences in implicit calling conventions).
This pattern is unsafe because of the difference in the default calling conventions between pure and native code (or mixed native and managed). When importing a function via `dllimport` into code compiled with `/clr:pure`, ensure that the declarations of each type in the signature are identical to the signature in the compiland that exports the function (being especially careful about differences in implicit calling conventions).

A virtual member function is especially prone to give unexpected results. However, even a non-virtual function should be tested to ensure that you get the correct results. If you are sure that you are getting the correct results, you can ignore this warning.
A virtual member function is especially prone to give unexpected results. However, even a nonvirtual function should be tested to ensure that you get the correct results. This warning can be ignored once you ensure the result is correct.

C4412 is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) and [dllexport, dllimport](../../cpp/dllexport-dllimport.md) for more information.
C4412 is off by default. For more information, see [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) and [`dllexport`, `dllimport`](../../cpp/dllexport-dllimport.md).

To resolve this warning, remove all functions from the type.

## Examples
## Example

The following sample generates C4412.
The following sample generates C4412:

```cpp
// C4412.cpp
// compile with: /c /W2 /clr:pure
#pragma warning (default : 4412)

Expand All @@ -52,7 +50,7 @@ int main() {
}
```

The following sample is a header file that declares two types. The `Unsafe` type is unsafe because it has a member function.
The following sample is a header file that declares two types. The `Unsafe` type is unsafe because it has a member function:

```cpp
// C4412.h
Expand All @@ -70,7 +68,7 @@ struct Safe {
};
```

This sample exports functions with the types defined in the header file.
This sample exports functions with the types defined in the header file:

```cpp
// C4412_2.cpp
Expand All @@ -85,9 +83,9 @@ __declspec(dllexport) Unsafe * __cdecl func() { return new Unsafe; }
__declspec(dllexport) Safe * __cdecl func2() { return new Safe; }
```

The default calling convention in a **/clr:pure** compilation is different from a native compilation. When C4412.h is included, `Test` defaults to `__clrcall`. If you compile and run this program (do not use **/c**), the program will throw an exception.
The default calling convention in a `/clr:pure` compilation is different from a native compilation. When `C4412.h` is included, `Test` defaults to `__clrcall`.

The following sample generates C4412.
The following sample generates C4412 and throws an exception at runtime:

```cpp
// C4412_3.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
---
description: "Learn more about: Compiler Warning (level 4) C4400"
title: "Compiler Warning (level 4) C4400"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 4, error) C4400"
title: "Compiler warning (level 4, error) C4400"
ms.date: "1/22/2025"
f1_keywords: ["C4400"]
helpviewer_keywords: ["C4400"]
ms.assetid: f135fe98-4f92-4e07-9d71-2621b36ee755
---
# Compiler Warning (level 4) C4400
# Compiler warning (level 4, error) C4400

'type' : const/volatile qualifiers on this type are not supported
> '*type*': `const`/`volatile` qualifiers on this type are not supported

The [const](../../cpp/const-cpp.md)and [volatile](../../cpp/volatile-cpp.md)qualifiers will not work with variables of common language runtime types.
The [`const`](../../cpp/const-cpp.md) and [`volatile`](../../cpp/volatile-cpp.md) qualifiers don't work with common language runtime typed variables.

## Example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
---
description: "Learn more about: Compiler Warning (level 4) C4435"
title: "Compiler Warning (level 4) C4435"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 4, off) C4435"
title: "Compiler Warning (level 4, off) C4435"
ms.date: "1/22/2025"
f1_keywords: ["C4435"]
helpviewer_keywords: ["C4435"]
ms.assetid: a04524af-2b71-4ff9-9729-d9d1d1904ed7
---
# Compiler Warning (level 4) C4435
# Compiler warning (level 4, off) C4435

'class1' : Object layout under /vd2 will change due to virtual base 'class2'
> '*derived_class*': Object layout under `/vd2` will change due to virtual base '*base_class*'

This warning is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) for more information.
This warning is off by default. For more information, see [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).

Under the default compile option of /vd1, the derived class does not have a `vtordisp` field for the indicated virtual base. If /vd2 or `#pragma vtordisp(2)` is in effect, a `vtordisp` field will be present, changing the object layout. This can lead to binary compatibility problems if interacting modules are compiled with different `vtordisp` settings.
Under the default compile option of `/vd1`, the derived class doesn't have a `vtordisp` field for the indicated virtual base. If `/vd2` or `#pragma vtordisp(2)` is in effect, a `vtordisp` field is present, changing the object layout. This difference can lead to binary compatibility problems if interacting modules are compiled with different `vtordisp` settings.

## Example

Expand All @@ -34,5 +33,5 @@ class B : public virtual A // C4435

## See also

[vtordisp](../../preprocessor/vtordisp.md)<br/>
[/vd (Disable Construction Displacements)](../../build/reference/vd-disable-construction-displacements.md)
[`vtordisp`](../../preprocessor/vtordisp.md)\
[`/vd` (Disable Construction Displacements)](../../build/reference/vd-disable-construction-displacements.md)
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
---
description: "Learn more about: Compiler Warning (level 4) C4437"
title: "Compiler Warning (level 4) C4437"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1 and level 4, off) C4437"
title: "Compiler warning (level 1 and level 4, off) C4437"
ms.date: "1/22/2025"
f1_keywords: ["C4437"]
helpviewer_keywords: ["C4437"]
ms.assetid: dc07e350-20eb-474c-a7ad-f841ae7ec339
---
# Compiler Warning (level 4) C4437
# Compiler warning (level 1 and level 4, off) C4437

dynamic_cast from virtual base 'class1' to 'class2' could fail in some contexts Compile with /vd2 or define 'class2' with #pragma vtordisp(2) in effect
> `dynamic_cast` from virtual base '*base_class*' to '*derived_class*' could fail in some contexts

This warning is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) for more information.
This warning is off by default. For more information, see [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).

The compiler has encountered a **`dynamic_cast`** operation with the following characteristics.
A `dynamic_cast` operation is used when:

- The cast is from a base class pointer to a derived class pointer.

- The derived class virtually inherits the base class.
- The derived class doesn't have a `vtordisp` field for the virtual base.
- The cast is found in a constructor or destructor of the derived class, or a class that inherits from the derived class. Otherwise, compiler warning [C4436](compiler-warning-level-1-c4436.md) is emitted issued of C4435.

- The derived class does not have a `vtordisp` field for the virtual base.

- The cast is not found in a constructor or destructor of the derived class, or some class which further inherits from the derived class (otherwise, compiler warning C4436 will be issued).

The warning indicates that the **`dynamic_cast`** might not perform correctly if it is operating on a partially-constructed object. This situation occurs when the enclosing function is called from a constructor or destructor of a class that inherits the derived class that is named in the warning. If the derived class that is named in the warning is never further derived, or the enclosing function is not called during object construction or destruction, the warning can be ignored.
This warning indicates that the `dynamic_cast` might not perform correctly when applied to a partially constructed object. This situation occurs when the enclosing function is called from a constructor or destructor of a class that inherits from *derived_class*. You can ignore the error if *derived_class* is never further derived, or the enclosing function isn't called during object construction or destruction.

## Example

The following sample generates C4437 and demonstrates the code generation issue that arises from the missing `vtordisp` field.
The following sample generates C4437 and demonstrates the code generation issue that arises from the missing `vtordisp` field:

```cpp
// C4437.cpp
Expand Down Expand Up @@ -76,6 +72,6 @@ int main()

## See also

[dynamic_cast Operator](../../cpp/dynamic-cast-operator.md)<br/>
[vtordisp](../../preprocessor/vtordisp.md)<br/>
[Compiler Warning (level 1) C4436](../../error-messages/compiler-warnings/compiler-warning-level-1-c4436.md)
[`dynamic_cast` Operator](../../cpp/dynamic-cast-operator.md)\
[`vtordisp`](../../preprocessor/vtordisp.md)\
[Compiler Warning (level 1) C4436](compiler-warning-level-1-c4436.md)
Loading