RFC: Fix overloading issue in <cmath>
Loren James Rittle
rittle@latour.rsch.comm.mot.com
Wed Apr 16 08:05:00 GMT 2003
> By overloading some plain good C old math functions, C++ has broken
> some (legacy) working programs:
> #include <math.h>
>
> int main()
> {
> return !cos(2);
> }
> Comments?
[Patch removed.]
Hey Gaby, interesting technique. Similar to stuff found in _Modern
C++ Design_ (Phil and I both read it, they cover the
invalid-declaration-which-comes-from-template-is-ignored trick very
well). For my own information:
Humm, is there a way to adapt that same technique to look for
e.g. global declarations which may or may not have been provided by a
system C header? Could we write a robust __is_declared<> predicate?
How does a patch to <cmath> affect the above testcase? ;-) Perhaps
some ports are being configured differently than what I see here
(which is the root reason I'm asking), but your posted test case (a)
works fine on i386-unknown-freebsd[45] i.e. w/ and w/o C99 support and
(b) preprocesses to include none of the changes you are proposing.
Along that line, if possible, please install a new test case and
report what platform it fails upon without the patch (unless it indeed
merely fixes an existing test case).
Regards,
Loren
More information about the Libstdc++
mailing list