For the following function:
int foo(int a) __attribute__((enable_if(a > 0, “”)));
The callee should be able to reasonably assume that foo will be called iff a > 0. However, this is currently not the case. One can grab the address of foo and use the resultant function pointer to call foo with any value of a.
Additionally, given a situation like:
int bar(int a) __attribute__((overloadable, enable_if(a > 0, “”))); int bar(int a) __attribute__((overloadable)); int baz(int a) { return bar(a); }
One may only indirectly call bar by making a wrapper like baz, because there’s no way to disambiguate which bar you’re referring to in &bar.
This patch fixes both of these issues by making it an error to take the address of a function with an enable_if attribute, unless the condition in said attribute is always true.
Converting the RHS to the type of the LHS seems to only be appropriate for simple assignment operators, not for arbitrary binary operators.