https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88738
Bug ID: 88738
Summary: treat shared_ptr and unique_ptr more like plain old
pointers
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: drepper.fsp+rhbz at gmail dot com
Target Milestone: ---
The implementations are obviously more complicated but the warning handling the
current implementation allows is less than optimal. For the test case below
gcc (8.2.1, current trunk) doesn't emit any warning, even with -Wall. clang on
the other hand reports
$ clang++ -c -O -Wall -g v.cc -std=gnu++17
v.cc:8:9: warning: equality comparison result unused [-Wunused-comparison]
res == nullptr;
~~~~^~~~~~~~~~
v.cc:8:9: note: use '=' to turn this equality comparison into an assignment
res == nullptr;
^~
=
Test (compile with -std=c++17):
#include <memory>
using type = std::shared_ptr<int>;
type f(int a) {
auto res = std::make_shared<int>(3);
if (a == 0)
res == nullptr; // <- obviously incorrect
return res;
}