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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs