Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ helpviewer_keywords: ["C4355"]

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

## Remarks

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. 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. 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:
## Example

The following example generates C4355:

```cpp
// C4355.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
---
description: "Learn more about: Compiler Warning (level 1) C4311"
title: "Compiler Warning (level 1) C4311"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4311"
ms.date: 11/04/2016
f1_keywords: ["C4311"]
helpviewer_keywords: ["C4311"]
ms.assetid: ddc579d0-d051-47bc-915d-71ffb32323c9
---
# Compiler Warning (level 1) C4311

'variable' : pointer truncation from 'type' to 'type'
> 'variable' : pointer truncation from 'type' to 'type'

## Remarks

This warning detects 64-bit pointer truncation issues. For example, if code is compiled for a 64-bit architecture, the value of a pointer (64 bits) will be truncated if it is assigned to an **`int`** (32 bits). For more information, see [Rules for Using Pointers](/windows/win32/WinProg64/rules-for-using-pointers).

For additional information about common causes of warning C4311, see [Common Compiler Errors](/windows/win32/WinProg64/common-compiler-errors).

## Example

The following code example generates C4311 when compiled for a 64-bit target, and then demonstrates how to fix it:

```cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
---
description: "Learn more about: Compiler Warning (level 1) C4312"
title: "Compiler Warning (level 1) C4312"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4312"
ms.date: 11/04/2016
f1_keywords: ["C4312"]
helpviewer_keywords: ["C4312"]
ms.assetid: 541906ed-4f62-4bcb-947f-cf9ae7411bcb
---
# Compiler Warning (level 1) C4312

'operation' : conversion from 'type1' to 'type2' of greater size
> 'operation' : conversion from 'type1' to 'type2' of greater size

## Remarks

This warning detects an attempt to assign a 32-bit value to a 64-bit pointer type, for example, casting a 32-bit **`int`** or **`long`** to a 64-bit pointer.

This can be an unsafe conversion even for pointer values that fit in 32 bits when sign extension occurs. If a negative 32-bit integer is assigned to a 64-bit pointer type, sign extension causes the pointer value to reference a memory address different from the value of the integer.

This warning is only issued for 64-bit compilation targets. For more information, see [Rules for Using Pointers](/windows/win32/WinProg64/rules-for-using-pointers).

## Example

The following code example generates C4312 when it is compiled for 64-bit targets:

```cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Warning (level 1) C4313"
title: "Compiler Warning (level 1) C4313"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4313"
ms.date: 11/04/2016
f1_keywords: ["C4313"]
helpviewer_keywords: ["C4313"]
ms.assetid: bcf64191-e2cf-452e-97b4-423fcec2d07c
---
# Compiler Warning (level 1) C4313

'function' : 'format specifier' in format string conflicts with argument number of type 'type'
> 'function' : 'format specifier' in format string conflicts with argument number of type 'type'

## Remarks

There is a conflict between the format specified and the value that you are passing. For example, you passed a 64-bit parameter to an unqualified %d format specifier, which expects a 32-bit integer parameter. This warning is only in effect when the code is compiled for 64-bit targets.

## Example

The following code sample generates C4313 when it is compiled for a 64-bit target.
The following code example generates C4313 when it is compiled for a 64-bit target.

```cpp
// C4313.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
description: "Learn more about: Compiler Warning (level 1) C4319"
title: "Compiler Warning (level 1) C4319"
ms.date: "01/18/2018"
description: "Learn more about: Compiler Warning (level 1) C4319"
ms.date: 01/18/2018
f1_keywords: ["C4319"]
helpviewer_keywords: ["C4319"]
ms.assetid: 1fac8048-9bd6-4552-a21c-192c67772bb9
---
# Compiler Warning (level 1) C4319

> '~' : zero extending '*type1*' to '*type2*' of greater size

## Remarks

The result of the **~** (bitwise complement) operator is unsigned and then zero-extended when it is converted to a larger type.

## Example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Warning (level 1) C4325"
title: "Compiler Warning (level 1) C4325"
ms.date: "08/27/2018"
description: "Learn more about: Compiler Warning (level 1) C4325"
ms.date: 08/27/2018
f1_keywords: ["C4325"]
helpviewer_keywords: ["C4325"]
ms.assetid: 8127a08c-d626-481b-aa7b-04a3fdc9a9ec
---
# Compiler Warning (level 1) C4325

> attributes for standard section '*section*' ignored

## Remarks

You may not change the attributes of a standard section. For example:
You may not change the attributes of a standard section.

## Example

For example:

```cpp
#pragma section(".sdata", long)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Warning (level 1) C4326"
title: "Compiler Warning (level 1) C4326"
ms.date: "08/27/2018"
description: "Learn more about: Compiler Warning (level 1) C4326"
ms.date: 08/27/2018
f1_keywords: ["C4326"]
helpviewer_keywords: ["C4326"]
ms.assetid: d44d2c4e-9456-42d3-b35b-4ba4b2d42ec7
---
# Compiler Warning (level 1) C4326

Expand All @@ -16,7 +15,7 @@ A function returned a type other than *type1*. For example, using [/Za](../../bu

## Example

The following sample generates C4326 and shows how to fix it:
The following example generates C4326 and shows how to fix it:

```cpp
// C4326.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
---
description: "Learn more about: Compiler Warning (level 1) C4329"
title: "Compiler Warning (level 1) C4329"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4329"
ms.date: 11/04/2016
f1_keywords: ["C4329"]
helpviewer_keywords: ["C4329"]
---
# Compiler Warning (level 1) C4329

> alignment specifier is ignored on enum

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:
## Remarks

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.

## Example

The following example generates C4329:

```cpp
// C4329.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Warning (level 1) C4333"
title: "Compiler Warning (level 1) C4333"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4333"
ms.date: 11/04/2016
f1_keywords: ["C4333"]
helpviewer_keywords: ["C4333"]
ms.assetid: d3763c52-6110-4da0-84db-5264e3f3f166
---
# Compiler Warning (level 1) C4333

'operator' : right shift by too large amount, data loss
> 'operator' : right shift by too large amount, data loss

## Remarks

A right shift operation was too large an amount. All significant bits are shifted out and the result will always be zero.

## Example

The following sample generates C4333.
The following example generates C4333.

```cpp
// C4333.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Warning (level 1) C4340"
title: "Compiler Warning (level 1) C4340"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4340"
ms.date: 11/04/2016
f1_keywords: ["C4340"]
helpviewer_keywords: ["C4340"]
ms.assetid: ddd5344b-5167-4c55-a318-20615052fd54
---
# Compiler Warning (level 1) C4340

'value' : value wrapped from positive to negative value
> 'value' : value wrapped from positive to negative value

## Remarks

The **`enum`** value is greater than the largest **`enum`** positive value wrapped around to a negative value.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Warning (level 1) C4342"
title: "Compiler Warning (level 1) C4342"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4342"
ms.date: 11/04/2016
f1_keywords: ["C4342"]
helpviewer_keywords: ["C4342"]
ms.assetid: 47d4d5ab-069f-4cdc-98c3-10d649577a37
---
# Compiler Warning (level 1) C4342

behavior change: '*function*' called, but a member operator was called in previous versions
> behavior change: '*function*' called, but a member operator was called in previous versions

## Remarks

In versions of Visual C++ before Visual Studio 2002, a member was called, but this behavior has been changed and the compiler now finds the best match in namespace scope.

Expand All @@ -18,7 +19,9 @@ This warning should be disabled after you successfully port your code to the cur

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 C4342:
## Example

The following example generates C4342:

```cpp
// C4342.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Warning (level 1) C4344"
title: "Compiler Warning (level 1) C4344"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4344"
ms.date: 11/04/2016
f1_keywords: ["C4344"]
helpviewer_keywords: ["C4344"]
ms.assetid: cd20859d-f07f-4c70-904b-cb756a53b1ed
---
# Compiler Warning (level 1) C4344

behavior change: use of explicit template arguments results in call to 'function'
> behavior change: use of explicit template arguments results in call to 'function'

## Remarks

A call to a function using explicit template arguments calls a different function than it would if explicit arguments had not been specified
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Warning (level 1) C4346"
title: "Compiler Warning (level 1) C4346"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4346"
ms.date: 11/04/2016
f1_keywords: ["C4346"]
helpviewer_keywords: ["C4346"]
ms.assetid: 68ee562d-cca9-4a2a-9a1b-14ad1a1e7396
---
# Compiler Warning (level 1) C4346

'name' : dependent name is not a type
> 'name' : dependent name is not a type

## Remarks

The [typename](../../cpp/typename.md) keyword is required if a dependent name is to be treated as a type. For code that works the same in all versions of Visual C++, add **`typename`** to the declaration.

The following sample generates C4346:
## Examples

The following example generates C4346:

```cpp
// C4346.cpp
Expand All @@ -25,7 +28,7 @@ struct C {
};
```

The following samples shows other examples where the **`typename`** keyword is required:
The following shows other examples where the **`typename`** keyword is required:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plain replacing of "samples" with "examples" yield "examples shows other examples", hence I just remove "samples".


```cpp
// C4346b.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Warning (level 1) C4348"
title: "Compiler Warning (level 1) C4348"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4348"
ms.date: 11/04/2016
f1_keywords: ["C4348"]
helpviewer_keywords: ["C4348"]
ms.assetid: 816010eb-6079-48d5-a41b-0fc4d67cfe4c
---
# Compiler Warning (level 1) C4348

'type' : redefinition of default parameter : parameter number
> 'type' : redefinition of default parameter : parameter number

## Remarks

A template parameter was redefined.

The following sample generates C4348:
## Example

The following example generates C4348:

```cpp
// C4348.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Warning (level 1) C4350"
title: "Compiler Warning (level 1) C4350"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Warning (level 1) C4350"
ms.date: 11/04/2016
f1_keywords: ["C4350"]
helpviewer_keywords: ["C4350"]
ms.assetid: 4cc8ed67-64c4-4da5-a7a5-a639232baa23
---
# Compiler Warning (level 1) C4350

behavior change: 'member1' called instead of 'member2'
> behavior change: 'member1' called instead of 'member2'

## Remarks

An rvalue cannot be bound to a non-const reference. In versions of Visual C++ before Visual Studio 2003, it was possible to bind an rvalue to a non-const reference in a direct initialization. This code now gives a warning.

Expand All @@ -20,7 +21,9 @@ If you get this warning, examine your code to see if it depends on binding rvalu

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 C4350:
## Example

The following example generates C4350:

```cpp
// C4350.cpp
Expand Down
Loading