Skip to content

Commit 9e29183

Browse files
authored
Merge pull request #4984 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main)
2 parents 2b2a101 + abf42ab commit 9e29183

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/c-language/cpp-integer-limits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Microsoft C also permits the declaration of sized integer variables, which are i
2323
|**UCHAR_MAX**|Maximum value for a variable of type **`unsigned char`**.|255 (0xff)|
2424
|**CHAR_MIN**|Minimum value for a variable of type **`char`**.|-128; 0 if /J option used|
2525
|**CHAR_MAX**|Maximum value for a variable of type **`char`**.|127; 255 if /J option used|
26-
|**MB_LEN_MAX**|Maximum number of bytes in a multicharacter constant.|5|
26+
|**MB_LEN_MAX**|Maximum number of bytes in a multibyte character.|5|
2727
|**SHRT_MIN**|Minimum value for a variable of type **`short`**.|-32768|
2828
|**SHRT_MAX**|Maximum value for a variable of type **`short`**.|32767|
2929
|**USHRT_MAX**|Maximum value for a variable of type **`unsigned short`**.|65535 (0xffff)|

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ helpviewer_keywords: ["C4834"]
1313

1414
Starting in the C++17 Standard, the `[[nodiscard]]` attribute specifies that a function's return value isn't intended to be discarded. If a caller discards the return value, the compiler generates warning C4834.
1515

16-
To resolve this warning, consider why your code doesn't use the return value. Your use of the function may not match its intent. You can circumvent the warning by using a cast to **`void`**.
16+
To resolve this warning, consider why your code doesn't use the return value. Your use of the function may not match its intent. You can circumvent the warning by assigning the value to **`std::ignore`** or by using a cast to **`void`** (see [Warning C26457](../../code-quality/c26457.md)).
1717

1818
This warning was introduced in Visual Studio 2017 version 15.3 as a level 3 warning. It was changed to a level 1 warning in Visual Studio 2017 version 15.7. Code that compiled without warnings in versions of the compiler before Visual Studio 2017 version 15.3 can now generate C4834. For information on how to disable warnings introduced in a particular compiler version or later, see [Compiler warnings by compiler version](compiler-warnings-by-compiler-version.md).
1919

@@ -29,7 +29,7 @@ To turn off the warning for an entire project in the Visual Studio IDE:
2929

3030
## Example
3131

32-
This sample generates C4834, and shows a way to fix it:
32+
This sample generates C4834, and shows three ways to fix it:
3333

3434
```cpp
3535
// C4834.cpp
@@ -42,8 +42,12 @@ int square_of(int i) { return i * i; }
4242
int main()
4343
{
4444
square_of(42); // warning C4834: discarding return value of function with 'nodiscard' attribute
45-
// to fix, make use of the return value, as shown here:
45+
// If ignoring the [[nodiscard] attribute is unintentional, to fix the warning, make use of the return value, as shown here:
4646
// std::cout << "square_of(42) = " << square_of(42) << "\n";
47+
// If discarding the nodiscard value is intentional, but you cannot fix it another way (for example, if the function marked [[nodiscard]] is from a third-party dependency), you can also suppress the warning by assigning to std::ignore, as shown here:
48+
// std::ignore = square_of(42); // Ok, C++ 11 and higher
49+
// You can also suppress the warning by casting the return result to (void), but the intent of the cast may not be clear. This may produce warning C26457 depending on your code analysis settings.
50+
// (void) square_of(42); // warning C26457 if enabled
4751
return 0;
4852
}
4953
```

0 commit comments

Comments
 (0)