Skip to content

Commit 16bed43

Browse files
author
Colin Robertson
committed
Add C4463 per DevDiv 126442
1 parent 7f2afb2 commit 16bed43

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@
296296
## [Compiler Warning (level 4) C4460](compiler-warning-level-4-c4460.md)
297297
## [Compiler Warning (level 1) C4461](compiler-warning-level-1-c4461.md)
298298
## [Compiler Warning (level 1) C4462](compiler-warning-level-1-c4462.md)
299+
## [Compiler Warning (level 4) C4463](compiler-warning-level-4-c4463.md)
299300
## [Compiler Warning (level 1) C4470](compiler-warning-level-1-c4470.md)
300301
## [Compiler Warning (level 4) C4471](compiler-warning-level-4-c4471.md)
301302
## [Compiler Warning (level 4) C4481](compiler-warning-level-4-c4481.md)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: "Compiler Warning (level 4) C4463 | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/04/2016"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology:
8+
- "devlang-cpp"
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "error-reference"
11+
f1_keywords:
12+
- "C4463"
13+
dev_langs:
14+
- "C++"
15+
helpviewer_keywords:
16+
- "C4463"
17+
ms.assetid: a07ae70c-db4e-472b-8b58-9137d9997323
18+
caps.latest.revision: 0
19+
author: "corob-msft"
20+
ms.author: "corob"
21+
manager: "ghogen"
22+
translation.priority.ht:
23+
- "cs-cz"
24+
- "de-de"
25+
- "es-es"
26+
- "fr-fr"
27+
- "it-it"
28+
- "ja-jp"
29+
- "ko-kr"
30+
- "pl-pl"
31+
- "pt-br"
32+
- "ru-ru"
33+
- "tr-tr"
34+
- "zh-cn"
35+
- "zh-tw"
36+
---
37+
# Compiler Warning (level 4) C4463
38+
39+
> overflow; assigning *value* to bit-field that can only hold values from *low_value* to *high_value*
40+
41+
The assigned *value* is outside the range of values that the bit-field can hold. Signed bit-field types use the high-order bit for the sign, so if *n* is the bit-field size, the range for signed bit-fields is -2<sup>n-1</sup> to 2<sup>n-1</sup>-1, while unsigned bit-fields have a range from 0 to 2<sup>n</sup>-1.
42+
43+
## Example
44+
45+
This example generates C4463 because it attempts to assign a value of 3 to a bit-field of type `int` with a size of 2, which has a range from -2 to 1.
46+
47+
To fix this issue, you can change the assigned value to something in the allowed range. If the bit-field is intended to hold unsigned values in the range from 0 to 3, you can change the declaration type to `unsigned`. If the field is intended to hold values in the range -4 to 3, then you can change the bit-field size to 3.
48+
49+
```cpp
50+
// C4463_overflow.cpp
51+
// compile with: cl /W4 /EHsc C4463_overflow.cpp
52+
struct S {
53+
int x : 2; // int type treats high-order bit as sign
54+
};
55+
56+
int main() {
57+
S s;
58+
s.x = 3; // warning C4463: overflow; assigning 3
59+
// to bit-field that can only hold values from -2 to 1
60+
// To fix, change assigned value to fit in range,
61+
// increase size of bitfield, and/or change base type
62+
// to unsigned.
63+
}
64+
```

docs/error-messages/compiler-warnings/compiler-warnings-c4400-through-c4599.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ f1_keywords:
3939
- "C4457"
4040
- "C4458"
4141
- "C4459"
42-
- "C4463"
4342
- "C4464"
4443
- "C4472"
4544
- "C4480"
@@ -101,7 +100,6 @@ helpviewer_keywords:
101100
- "C4457"
102101
- "C4458"
103102
- "C4459"
104-
- "C4463"
105103
- "C4464"
106104
- "C4472"
107105
- "C4480"
@@ -217,7 +215,7 @@ You may find additional assistance for errors and warnings on the MSDN public fo
217215
|[Compiler Warning (level 4) C4460](../../error-messages/compiler-warnings/compiler-warning-level-4-c4460.md)|'WinRT&#124;managed' operator '*operator*', has parameter passed by reference. 'WinRT&#124;managed' operator '*operator*' has different semantics from C++ operator '*cpp_operator*', did you intend to pass by value?|
218216
|[Compiler Warning (level 1) C4461](../../error-messages/compiler-warnings/compiler-warning-level-1-c4461.md)|'*classname*': this class has a finalizer '!*finalizer*' but no destructor '~*dtor*'|
219217
|[Compiler Warning (level 1) C4462](../../error-messages/compiler-warnings/compiler-warning-level-1-c4462.md)|'*type*' : cannot determine the GUID of the type. Program may fail at runtime.|
220-
|Compiler warning C4463|overflow; assigning '*value*' to bit-field that can only hold values from '*min_value*' to '*max_value*'|
218+
|[Compiler warning (level 4) C4463](compiler-warning-level-4-c4463.md)|overflow; assigning '*value*' to bit-field that can only hold values from '*min_value*' to '*max_value*'|
221219
|Compiler warning C4464|relative include path contains '..'|
222220
|[Compiler Warning (level 1) C4470](../../error-messages/compiler-warnings/compiler-warning-level-1-c4470.md)|floating-point control pragmas ignored under /clr|
223221
|[Compiler warning (level 4) C4471](compiler-warning-level-4-c4471.md)|'*enumeration*': a forward declaration of an unscoped enumeration must have an underlying type (int assumed)|

docs/error-messages/tool-errors/linker-tools-error-lnk1120.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ translation.priority.mt:
4040

4141
Error LNK1120 reports the count (*number*) of unresolved external symbol errors for this link operation. Most unresolved external symbol errors are reported individually by [Linker Tools Error LNK2001](../../error-messages/tool-errors/linker-tools-error-lnk2001.md) and [Linker Tools Error LNK2019](../../error-messages/tool-errors/linker-tools-error-lnk2019.md), which precede this error message, once for each unresolved external symbol error.
4242

43-
To fix this error, correct all of the other unresolved external errors that precede it in the build output. This error is not reported when no unresolved external errors remain.
43+
To fix this error, correct all of the other unresolved external errors or other linker errors that precede it in the build output. This error is not reported when no unresolved external errors remain.

0 commit comments

Comments
 (0)