This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Fix overloading issue in <cmath>


Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com> writes:

| > 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:

Ah, it is good to know there is a good reference on that topic out
there [by now, you know that I never had the time to read the copy I
got :-(] 

| 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?

My first reaction would be "No".  But the template machinery has
proven to be surprising more than often.  But indeed that would be
helpful (which explains why it is on the top of the compile-time
reflection thingies I want to have). 

| How does a patch to <cmath> affect the above testcase?  ;-) 

In my local tree (on an i686-pc-linux), the above testcase when
modified to read

   #include <math.h>
   int main()
   {
      return !std::cos(2);
   }

fails without the patch -- but get fixed with it.

| 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.

If the above testcase success then that means we're nto getting the
<math.h> stuff right.  The point is:  It should fail both with
<math.h> and <cmath>.

| 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).

Sure.  I firstly just wanted to have some opinions here on the first cut.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]