A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/43670 below:

Wzero-as-null-pointer-constant warns when using `operator<=>` · Issue #43670 · llvm/llvm-project · GitHub

Extended Description
#include <compare>

auto b = 1 <=> 2 < 0;

Outputs:

<source>:3:20: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]

auto b = 1 <=> 2 < 0;

                   ^

                   nullptr

1 warning generated.

Compiler returned: 0

See it live: https://godbolt.org/z/9a8cnD

Technically, the warning is accurate. User code has a literal 0 that is being passed to a function accepting a nullptr. However, this is an implementation detail of the standard library and the intended interface for use (users should not use nullptr there), so we should not warn users for doing so (and definitely should not direct them to change their code).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4