public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tobias dot oberstein at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/16668] New: ::sin(double) should be only std::sin(double)
Date: Thu, 22 Jul 2004 07:59:00 -0000	[thread overview]
Message-ID: <20040722075941.16668.tobias.oberstein@gmx.de> (raw)

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

-- 
           Summary: ::sin(double) should be only std::sin(double)
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot oberstein at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16668


             reply	other threads:[~2004-07-22  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-22  7:59 tobias dot oberstein at gmx dot de [this message]
2004-07-22  8:48 ` [Bug libstdc++/16668] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040722075941.16668.tobias.oberstein@gmx.de \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).