Skip to content

Commit 5aa5f27

Browse files
TylerMSFTTylerMSFT
authored andcommitted
add fix for github #4725
1 parent cb4de12 commit 5aa5f27

File tree

1 file changed

+2
-2
lines changed
  • docs/error-messages/compiler-warnings

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn about the cause and fixes for Compiler warning (level 1) C4834."
33
title: "Compiler warning (Level 1) C4834"
4-
ms.date: 07/26/2021
4+
ms.date: 01/18/2024
55
f1_keywords: ["C4834"]
66
helpviewer_keywords: ["C4834"]
77
---
@@ -11,7 +11,7 @@ helpviewer_keywords: ["C4834"]
1111
1212
## Remarks
1313

14-
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.
14+
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. Although this attribute was introduced in C++17, the compiler respects this attribute and generates warnings related to it when using `/std:c++14` and later.
1515

1616
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 casting it to **`void`** if discarding the value is intentional.
1717
Assignment to **`std::ignore`** is preferred over casting to **`void`** in C++11 and higher, as it makes your intent clearer and will not trigger [Warning C26457](../../code-quality/c26457.md) if enabled in your code analysis settings.

0 commit comments

Comments
 (0)