https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92375
Bug ID: 92375 Summary: Warn on suspicious taking of function address instead of calling a function Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- Consider the simple example: bool function(); bool test() { bool result = function; if (result) { return 1; } else { return 2; } } Students and scholars often forget to put braces to actually call the function. Unfortunately GCC does not give a warning that is implemented in other compilers: <source>:4:19: warning: address of function 'function' will always evaluate to 'true' [-Wpointer-bool-conversion] bool result = function; ~~~~~~ ^~~~~~~~ <source>:4:19: note: prefix with the address-of operator to silence this warning bool result = function; ^ & <source>:4:19: note: suffix with parentheses to turn this into a function call bool result = function; ^ () Please, add a warning.