[llvm-bugs] [Bug 47127] New: Inconsistencies with weak member symbols
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 12 02:01:47 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47127
Bug ID: 47127
Summary: Inconsistencies with weak member symbols
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: srhines at google.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk, rprichard at google.com
Filing this bug on behalf of Steven Moreland (smoreland@) and Ryan Prichard
(rprichard@). I tried searching to see if there was a duplicate or to find a
reasonable explanation for why this would behave differently, but ultimately, I
think that there is some bug here.
Expected behavior: The static or non-static member function can be nullptr if
it is weak, so the compiler must output a run-time check. For non-weak
functions, the compiler should optimize out the check. GCC works as expected,
and Clang also works for static member functions, but it sometimes assumes that
a non-static weak member function is non-null.
Clang's behavior seems inconsistent. In particular, it optimizes "if
(&A::instance_weak != nullptr) ..." but not "return &A::instance_weak !=
nullptr;".
https://godbolt.org/z/4xec88
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200812/7490a562/attachment.html>
More information about the llvm-bugs
mailing list