[llvm-bugs] [Bug 43904] New: Warn on suspicious taking of function address instead of calling a function
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 5 03:07:13 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=43904
Bug ID: 43904
Summary: Warn on suspicious taking of function address instead
of calling a function
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: antoshkka at gmail.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
Consider the simple example:
bool function();
int test() {
auto result = function;
if (result) {
return 1;
} else {
return 2;
}
}
Students and scholars often forget to put braces to actually call the function.
Please, extend the -Wpointer-bool-conversion warning to detect the above case
with auto and warn:
<source>:4:19: warning: address of function 'function' will always evaluate to
'true' [-Wpointer-bool-conversion]
if (result) {
^~~~~~
<source>:4:19: note: prefix with the address-of operator to silence this
warning
auto result = function;
^
&
<source>:4:19: note: suffix with parentheses to turn this into a function call
auto result = function;
^
()
--
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/20191105/524fa0e6/attachment.html>
More information about the llvm-bugs
mailing list