https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103945
Bug ID: 103945
Summary: No warning for ordered comparison of function pointers
?
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
For this C++ code:
$ more jan7f.cc
typedef int (*FP)(void);
bool f( FP fp1, FP fp2)
{
return fp1 < fp2;
}
gcc trunk says nothing:
$ /home/dcb/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -pedantic jan7f.cc
$
and clang-13 says something:
$ /usr/bin/clang++ -g -O2 -Wall -c jan7f.cc
jan7f.cc:6:13: warning: ordered comparison of function pointers ('FP' (aka 'int
(*)()') and 'FP') [-Wordered-compare-function-pointers]
return fp1 < fp2;
~~~ ^ ~~~
1 warning generated.
This kind of code appears in Fedora package engauge-digitizer,
so it does occur in the real world.