[PATCH] Warn on suspicious use of absolute value function
James Dennett
jdennett at googlers.com
Mon Jan 6 15:48:55 PST 2014
On Mon, Jan 6, 2014 at 12:30 PM, Marshall Clow <mclow.lists at gmail.com> wrote:
>
> Two questions:
> * Is this meant to be just for ‘abs’, or will it be generalized for all the calls in <math.h>?
> * What about in C++ code, where there can be many functions named “abs” that take different arguments? What will this patch do in that case?
> [ Ok, they’re named std::abs, but people hoist them into the global namespace _all the time_ ]
People including authors of <math.h> if they get it right; it should
provide the same overload set as <cmath> (and similarly for <stdlib.b>
and <cstdlib>). (Appendix D of the C++ standard describes this
behavior for the C compatibility headers.)
However, some (most?) implementations of <math.h> and/or <stdlib.h> do
get this wrong. We shouldn't assume that they have the right
overloads in the global namespace, but we also shouldn't assume that
they don't.
-- James
More information about the cfe-commits
mailing list