-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
@JonCavesMSFT reported:
My recent PR to add a warning for uses of
[[nodiscard]]that are ignored, C5240, has shown up an issue with the self-build:The header file
<memory_resource>contains the following line:Line 47 in 52b7b32
extern "C" _CRT_SATELLITE_1 _NODISCARD memory_resource* __cdecl null_memory_resource() noexcept; Which causes the compiler to emit the new warning: and if you currently call the function as follows:
void f() { null_memory_resource(); }Then no warning about discarding the return value is emitted.
If I change the declaration of
null_memory_resourceto:extern "C" _NODISCARD _CRT_SATELLITE_1 memory_resource* __cdecl null_memory_resource_2() noexcept;Then the new warning is not emitted and the call to the function does emit, "C4834: discarding return value of function with 'nodiscard' attribute".
To unblock the self-build I will, for now, make this warning off-by-default.
_CRT_SATELLITE_1 is defined to be __declspec(dllexport) or nothing in crtdefs.h; the issue is with an attribute like [[nodiscard]] occuring after a __declspec.
I observe that this also affects a lot of Special Math machinery.