[PATCH] Builtins and C++ and such (take 3)

Gabriel Dos Reis gdr@codesourcery.com
Mon Apr 1 07:30:00 GMT 2002


Roger Sayle <roger@eyesopen.com> writes:

[...]

| I think I also know why I hadn't seen the regressions earlier.  My
| first patch to cmath didn't reorder the double case for std::abs.
| See http://gcc.gnu.org/ml/gcc/gcc-patches/2002-03/msg/msg01513.html
| So the other moral of this affair is that cmath should probably also
| contain the prototype "int abs(int);"

>From a non-implementation details point of view, I argued while ago
(on the committee reflectors) about moving int abs(int) into <cmath>
but got no postive response.  Maybe it is time to ping the committee about
that issue.

It makes the following highly non-deterministic 

   #include <math.h>
   #include <iostream>

   void f(int) { std::cout << "int" << std::endl; }
   void f(double) { std::cout << "double" << std::endl; }

   int main()
   {
      f(std::abs(1));
      f(std::abs(1.0));
   }

There is no reason, the above should be non-deterministic.


-- Gaby



More information about the Libstdc++ mailing list