Bug 16668 - ::sin(double) should be only std::sin(double)
Summary: ::sin(double) should be only std::sin(double)
Status: RESOLVED DUPLICATE of bug 6257
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.3.1
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-22 07:59 UTC by tobias.oberstein
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tobias.oberstein 2004-07-22 07:59:41 UTC
when including <cmath>, the standard says that in particular T sin (T) where T =
float, double or long double will go to namespace std. However, for T = double,
sin will go into :: and std::, which causes trouble for people who implement
their own sin at ::

to reproduce
------------

#include <iostream>
#include <cmath>

typedef float T;              // OK.
//typedef double T;           // PROBLEM!
//typedef long double T;      // OK.

namespace foo
{
    T sin (T x)
    {
      std::cout << "custom sin () called" << std::endl;
      return (T) 0;
    }
}

using namespace foo;

int main ()
{
    sin ((T) 0);
    return 0;
}

-------------
the root of problem i guess (from "cmath")


#include <math.h>

namespace std {
...
  using ::sin;

  inline float
  sin(float __x)
  { return __builtin_sinf(__x); }

  inline long double
  sin(long double __x)
  { return __builtin_sinl(__x); }
...
}
-------------

"using ::sin;" drags ::sin into std, but doesn't remove it from ::
Comment 1 Andrew Pinski 2004-07-22 08:48:27 UTC
There is a dup of bug 6257.

*** This bug has been marked as a duplicate of 6257 ***