Skip to content

Repo sync for protected branch #5026

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 35 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
82046eb
Learn Editor: Update compiler-warnings-c4200-through-c4399.md
Rastaban Apr 18, 2024
b53cf58
Update compiler-warning-levels-2-and-4-c4200.md
Rastaban Apr 18, 2024
446b3b7
Update compiler-warning-level-1-c4218.md
Rastaban Apr 18, 2024
5f125ef
Update compiler-warning-levels-1-and-4-c4223.md
Rastaban Apr 18, 2024
895fa91
Update compiler-warning-level-1-c4229.md
Rastaban Apr 18, 2024
26ea44a
Update compiler-warning-level-4-c4233.md
Rastaban Apr 18, 2024
f0aa859
Update compiler-warning-level-4-c4235.md
Rastaban Apr 18, 2024
b687d53
Update compiler-warning-level-4-c4242.md
Rastaban Apr 18, 2024
ecc68e7
Update compiler-warning-level-1-c4251.md
Rastaban Apr 18, 2024
c22debe
Update compiler-warning-level-4-c4254.md
Rastaban Apr 19, 2024
edd85eb
Update compiler-warning-level-1-c4305.md
Rastaban Apr 19, 2024
ca6775a
Update compiler-warning-level-3-c4306.md
Rastaban Apr 19, 2024
71c5f3d
Update compiler-warning-level-3-c4310.md
Rastaban Apr 19, 2024
d40ca31
Update compiler-warning-c4355.md
Rastaban Apr 19, 2024
60879f0
Update compiler-warning-level-3-c4265.md
Rastaban Apr 19, 2024
bbb60aa
Update compiler-warning-level-4-c4324.md
Rastaban Apr 19, 2024
4c82c99
Update compiler-warning-level-1-c4329.md
Rastaban Apr 19, 2024
500deb3
Update compiler-warning-level-1-c4384.md
Rastaban Apr 19, 2024
36ea2b6
Update compiler-warning-c4355.md
Rastaban Apr 22, 2024
1e88c25
Update compiler-warning-level-1-c4329.md
Rastaban Apr 22, 2024
eec0436
Update compiler-warning-level-1-c4384.md
Rastaban Apr 22, 2024
50df6ea
Update compiler-warning-level-1-c4329.md
Rastaban Apr 22, 2024
5f47f75
Update compiler-warning-level-1-c4384.md
Rastaban Apr 22, 2024
377006d
Update compiler-warning-level-3-c4306.md
Rastaban Apr 22, 2024
263a6d2
Update compiler-warning-level-4-c4233.md
Rastaban Apr 22, 2024
d3fc69d
Update compiler-warning-level-4-c4235.md
Rastaban Apr 22, 2024
10abe54
Update compiler-warning-level-4-c4242.md
Rastaban Apr 22, 2024
0502827
Update compiler-warning-level-4-c4254.md
Rastaban Apr 22, 2024
1b1e469
Update compiler-warning-level-4-c4324.md
Rastaban Apr 22, 2024
1c7ac62
Update compiler-warning-level-4-c4254.md
Rastaban Apr 22, 2024
51f0dfc
Update compiler-warning-levels-1-and-4-c4223.md
Rastaban Apr 22, 2024
15055f4
Update compiler-warning-levels-2-and-4-c4200.md
Rastaban Apr 22, 2024
75297bc
Merge pull request #5552 from Rastaban/docs-editor/compiler-warnings-…
v-dirichards Apr 22, 2024
ccd6cee
Merge pull request #5559 from MicrosoftDocs/main
Albertyang0 Apr 23, 2024
24602ab
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs…
Apr 23, 2024
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
15 changes: 7 additions & 8 deletions docs/error-messages/compiler-warnings/compiler-warning-c4355.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
description: "Learn more about: Compiler Warning C4355"
title: "Compiler Warning C4355"
description: "Learn more about: Compiler Warning (level 1 and level 4, off) C4355"
title: "Compiler Warning (level 1 and level 4, off) C4355"
ms.date: "11/04/2016"
f1_keywords: ["C4355"]
helpviewer_keywords: ["C4355"]
ms.assetid: b819ecab-8a07-42d7-8fa4-1180d51626c0
---
# Compiler Warning C4355
# Compiler Warning (level 1 and level 4, off) C4355

'this' : used in base member initializer list
> '`this`': used in base member initializer list

The **`this`** pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class.
The `this` pointer is valid only within nonstatic member functions. It can't be used in the initializer list for a base class.

The base-class constructors and class member constructors are called before **`this`** constructor. In effect, you've passed a pointer to an unconstructed object to another constructor. If those other constructors access any members or call member functions on this, the result will be undefined. You should not use the **`this`** pointer until all construction has completed.
The base-class constructors and class member constructors are called before `this` constructor. This pattern is the same as passing a pointer to an unconstructed object to another constructor. If those other constructors access any members or call member functions on `this`, the result is undefined. You shouldn't use the `this` pointer until all construction is complete.

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 following sample generates C4355:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
---
description: "Learn more about: Compiler Warning (level 1) C4218"
title: "Compiler Warning (level 1) C4218"
description: "Learn more about: Compiler Warning (level 4) C4218"
title: "Compiler Warning (level 4) C4218"
ms.date: "11/04/2016"
f1_keywords: ["C4218"]
helpviewer_keywords: ["C4218"]
ms.assetid: d6c3cd90-4518-49e9-ae86-4ba9e2761d98
---
# Compiler Warning (level 1) C4218
# Compiler Warning (level 4) C4218

nonstandard extension used : must specify at least a storage class or a type
> nonstandard extension used: must specify at least a storage class or a type

With the default Microsoft extensions (/Ze), you can declare a variable without specifying a type or storage class. The default type is **`int`**.
With the default Microsoft extensions (`/Ze`), you can declare a variable without specifying a type or storage class. The default type is **`int`**.

## Example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
description: "Learn more about: Compiler Warning (level 1) C4229"
title: "Compiler Warning (level 1) C4229"
description: "Learn more about: Compiler Warning (level 1, Error) C4229"
title: "Compiler Warning (level 1, Error) C4229"
ms.date: "11/04/2016"
f1_keywords: ["C4229"]
helpviewer_keywords: ["C4229"]
ms.assetid: aadfc83b-1e5f-4229-bd0a-9c10a5d13182
---
# Compiler Warning (level 1) C4229
# Compiler Warning (level 1, Error) C4229

anachronism used : modifiers on data are ignored
> anachronism used: modifiers on data are ignored

Using a Microsoft modifier such as **`__cdecl`** on a data declaration is an outdated practice.

Expand All @@ -17,5 +16,5 @@ Using a Microsoft modifier such as **`__cdecl`** on a data declaration is an out
```cpp
// C4229.cpp
// compile with: /W1 /LD
int __cdecl counter; // C4229 cdecl ignored
int __cdecl counter; // C4229
```
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
description: "Learn more about: Compiler Warning (level 1) C4251"
title: "Compiler Warning (level 1) C4251"
description: "Learn more about: Compiler Warning (level 2) C4251"
title: "Compiler Warning (level 2) C4251"
ms.date: 12/01/2023
f1_keywords: ["C4251"]
helpviewer_keywords: ["C4251"]
---
# Compiler Warning (level 1) C4251
# Compiler Warning (level 2) C4251

> '*type*' : class '*type1*' needs to have dll-interface to be used by clients of class '*type2*'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
description: "Learn more about: Compiler Warning (level 1) C4305"
title: "Compiler Warning (level 1) C4305"
description: "Learn more about: Compiler Warning (level 1 and level 2 and level 4) C4305"
title: "Compiler Warning (level 1 and level 2 and level 4) C4305"
ms.date: "01/17/2018"
f1_keywords: ["C4305"]
helpviewer_keywords: ["C4305"]
---
# Compiler Warning (level 1) C4305

> '*context*' : truncation from '*type1*' to '*type2*'
> '*conversion*': truncation from '*type1*' to '*type2*'

## Remarks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ title: "Compiler Warning (level 1) C4329"
ms.date: "11/04/2016"
f1_keywords: ["C4329"]
helpviewer_keywords: ["C4329"]
ms.assetid: 4316f51a-2c56-4b3f-831e-65d24b83b65c
---
# Compiler Warning (level 1) C4329

__declspec(align()) is ignored on enum
> alignment specifier is ignored on enum

Use of the [align](../../cpp/align-cpp.md) keyword of the [__declspec](../../cpp/declspec.md) modifier is not allowed on an **`enum`**. The following sample generates C4329:
Use of the alignment specifiers on `enum` isn't allowed. This pattern includes the use of the [`align`](../../cpp/align-cpp.md) [`__declspec`](../../cpp/declspec.md) modifier. The following sample generates C4329:

```cpp
// C4329.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ title: "Compiler Warning (level 1) C4384"
ms.date: "11/04/2016"
f1_keywords: ["C4384"]
helpviewer_keywords: ["C4384"]
ms.assetid: fafa8eb2-cbfc-4edb-8b0f-511ff5d37ac0
---
# Compiler Warning (level 1) C4384

\#pragma 'make_public' should only be used at global scope
> `#pragma` '*pragma_name*' should only be used at global scope

The [make_public](../../preprocessor/make-public.md) pragma was applied incorrectly.
A `pragma` directive that must be applied at a global scope, was found in a different scope.

The warning applies to the following `pragma` directives:
* [`detect_mismatch`](../../preprocessor/detect-mismatch.md)
* `extern_absolute`
* [`make_public`](../../preprocessor/make-public.md)

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ helpviewer_keywords: ["C4265"]
---
# Compiler Warning (level 3, off) C4265

> 'class' : class has virtual functions, but destructor is not virtual
> '*classname*': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly

When a class has virtual functions but a nonvirtual destructor, objects of the type might not be destroyed properly when the class is destroyed through a base class pointer.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
---
description: "Learn more about: Compiler Warning (level 3) C4306"
title: "Compiler Warning (level 3) C4306"
description: "Learn more about: Compiler Warning (level 4) C4306"
title: "Compiler Warning (level 4) C4306"
ms.date: "08/27/2018"
f1_keywords: ["C4306"]
helpviewer_keywords: ["C4306"]
ms.assetid: 5b2192d7-402d-4b6d-8619-08105e7dcac7
---
# Compiler Warning (level 3) C4306
# Compiler Warning (level 4) C4306

> '*identifier*' : conversion from '*type1*' to '*type2*' of greater size
> '*conversion*': conversion from '*type1*' to '*type2*' of greater size

The identifier is type cast to a larger pointer. The unfilled high bits of the new type will be zero-filled.
The identifier is type cast to a larger pointer. The unfilled high bits of the new type are zero-filled.

This warning may indicate an unwanted conversion. The resulting pointer may not be valid.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
description: "Learn more about: Compiler Warning (level 4) C4310"
title: "Compiler Warning (level 3) C4310"
title: "Compiler Warning (level 4) C4310"
ms.date: 10/17/2023
f1_keywords: ["C4310"]
helpviewer_keywords: ["C4310"]
---
# Compiler Warning (level 4) C4310

cast truncates constant value
> cast truncates constant value

A constant value is cast to a smaller type. The compiler performs the cast, which truncates data. The following sample generates C4310:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
---
description: "Learn more about: Compiler Warning (level 4) C4233"
title: "Compiler Warning (level 4) C4233"
description: "Learn more about: Compiler Warning (level 1, Error) C4233"
title: "Compiler Warning (level 1, Error) C4233"
ms.date: "10/25/2017"
f1_keywords: ["C4233"]
helpviewer_keywords: ["C4233"]
ms.assetid: 9aa51fc6-8ef3-43b5-bafb-c9333cf60de3
---
# Compiler Warning (level 4) C4233
# Compiler Warning (level 1, Error) C4233

> nonstandard extension used : '*keyword*' keyword only supported in C++, not C
> nonstandard extension used: '*keyword*' keyword only supported in C++, not C

The compiler compiled your source code as C rather than C++, and you used a keyword that is only valid in C++. The compiler compiles your source file as C if the extension of the source file is .c or you use [/Tc](../../build/reference/tc-tp-tc-tp-specify-source-file-type.md).

This warning is automatically promoted to an error. If you wish to modify this behavior, use [#pragma warning](../../preprocessor/warning.md). For example, to make C4233 into a level 4 warning issue, add this line to your source code file:

```cpp
#pragma warning(4:4233)
```
This warning is always issued as an error. Use the [warning](../../preprocessor/warning.md) pragma to disable.
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
---
description: "Learn more about: Compiler Warning (level 4) C4235"
title: "Compiler Warning (level 4) C4235"
description: "Learn more about: Compiler Warning (level 1, Error) C4235"
title: "Compiler Warning (level 1, Error) C4235"
ms.date: "11/04/2016"
f1_keywords: ["C4235"]
helpviewer_keywords: ["C4235"]
ms.assetid: d4214799-d62c-4674-b4e2-9e201c303303
---
# Compiler Warning (level 4) C4235
# Compiler Warning (level 1, Error) C4235

nonstandard extension used : 'keyword' keyword not supported on this architecture
> nonstandard extension used: '*keyword*' keyword not supported on this architecture

The compiler does not support the keyword you used.
The compiler doesn't support the keyword you used on the architecture your build is targeting.

This warning is automatically promoted to an error. If you wish to modify this behavior, use [#pragma warning](../../preprocessor/warning.md). For example, to make C4235 into a level 2 warning, use the following line of code

```cpp
#pragma warning(2:4235)
```

in your source code file.
This warning is always issued as an error. Use the [warning](../../preprocessor/warning.md) pragma to disable.
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
description: "Learn more about: Compiler Warning (level 4) C4242"
title: "Compiler Warning (level 4) C4242"
description: "Learn more about: Compiler Warning (level 3, off) C4242"
title: "Compiler Warning (level 3, off) C4242"
ms.date: "11/04/2016"
f1_keywords: ["C4242"]
helpviewer_keywords: ["C4242"]
ms.assetid: 8df742e1-fbf1-42f3-8e93-c0e1c222dc7e
---
# Compiler Warning (level 4) C4242
# Compiler Warning (level 3, off) C4242

'identifier' : conversion from 'type1' to 'type2', possible loss of data
> '*identifier*': conversion from '*type1*' to '*type2*', possible loss of data

The types are different. Type conversion may result in loss of data. The compiler makes the type conversion.

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).

For additional information on C4242, see [Common Compiler Errors](/windows/win32/WinProg64/common-compiler-errors).
For more information on C4242, see [Common Compiler Errors](/windows/win32/WinProg64/common-compiler-errors).

The following sample generates C4242:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
description: "Learn more about: Compiler Warning (level 4) C4254"
title: "Compiler Warning (level 4) C4254"
description: "Learn more about: Compiler Warning (level 4, off) C4254"
title: "Compiler Warning (level 4, off) C4254"
ms.date: "11/04/2016"
f1_keywords: ["C4254"]
helpviewer_keywords: ["C4254"]
---
# Compiler Warning (level 4) C4254

'operator' : conversion from 'type1' to 'type2', possible loss of data
> '*operator*': conversion from '*type1*':'*field_bits*' to '*type2*':'*field_bits*', possible loss of data

A larger bit field was assigned to a smaller bit field. There could be a loss of data.

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 following sample generates C4254:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ title: "Compiler Warning (level 4) C4324"
ms.date: "11/04/2016"
f1_keywords: ["C4324"]
helpviewer_keywords: ["C4324"]
ms.assetid: 420fa929-d9c0-40b4-8808-2d8ad3ca8090
---
# Compiler Warning (level 4) C4324

'struct_name' : structure was padded due to __declspec(align())
> '*structname*': structure was padded due to alignment specifier

Padding was added at the end of a structure because you specified a [__declspec(align)](../../cpp/align-cpp.md) value.
Padding was added at the end of a structure because you specified an alignment specifier, such as [__declspec(align)](../../cpp/align-cpp.md).

For example, the following code generates C4324:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
description: "Learn more about: Compiler Warning (levels 1 and 4) C4223"
title: "Compiler Warning (levels 1 and 4) C4223"
description: "Learn more about: Compiler Warning (level 1 and level 4) C4223"
title: "Compiler Warning (level 1 and level 4) C4223"
ms.date: "11/04/2016"
f1_keywords: ["C4223"]
helpviewer_keywords: ["C4223"]
ms.assetid: 6fc44336-0250-4432-928b-fc5dbe7b7c1c
---
# Compiler Warning (levels 1 and 4) C4223
# Compiler Warning (level 1 and level 4) C4223

nonstandard extension used : non-lvalue array converted to pointer
> nonstandard extension used: non-lvalue array converted to pointer

In standard C, you cannot convert a non-lvalue array to a pointer. With the default Microsoft extensions ([/Ze](../../build/reference/za-ze-disable-language-extensions.md)), you can.
In standard C, you can't convert a nonlvalue array to a pointer. With the default Microsoft extensions ([`/Ze`](../../build/reference/za-ze-disable-language-extensions.md)), you can.
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
---
description: "Learn more about: Compiler Warning (levels 2 and 4) C4200"
title: "Compiler Warning (levels 2 and 4) C4200"
description: "Learn more about: Compiler Warning (level 2 and level 4) C4200"
title: "Compiler Warning (level 2 and level 4) C4200"
ms.date: "11/04/2016"
f1_keywords: ["C4200"]
helpviewer_keywords: ["C4200"]
ms.assetid: e44d6073-937f-42b7-acc1-65e802b475c6
---
# Compiler Warning (levels 2 and 4) C4200
# Compiler Warning (level 2 and level 4) C4200

nonstandard extension used : zero-sized array in struct/union
> nonstandard extension used: zero-sized array in struct/union

Indicates that a structure or union contains an array that has zero size.

Declaration of a zero-sized array is a Microsoft extension. This causes a Level-2 warning when a C++ file is compiled and a Level-4 warning when a C file is compiled. C++ compilation also gives this warning: "Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array." This example generates warning C4200:
C++ only:
> This member will be ignored by a defaulted constructor or copy/move assignment operator

This warning indicates that a structure or union contains an array that has zero size. Declaration of a zero-sized array is a nonstandard compiler extension. This causes a Level-2 warning when a C++ file is compiled and a Level-4 warning when a C file is compiled. This example generates warning C4200:

```cpp
// C4200.cpp
// compile by using: cl /W4 c4200.cpp
struct A {
int len;
int a[0]; // C4200
};
int main() {
}
```

This non-standard extension is often used to interface code with external data structures that have a variable length. If this scenario applies to your code, you can disable the warning:
This nonstandard extension is often used to interface code with external data structures that have a variable length. If this scenario applies to your code, you can disable the warning:

## Example

Expand All @@ -33,8 +32,7 @@ This non-standard extension is often used to interface code with external data s
// compile by using: cl /W4 c4200a.cpp
#pragma warning(disable : 4200)
struct A {
int len;
int a[0];
};
int main() {
}
```
Loading