public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dg001 at t-online dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/26110] using directive breaks ADL
Date: Mon, 06 Feb 2006 20:06:00 -0000	[thread overview]
Message-ID: <20060206200640.29035.qmail@sourceware.org> (raw)
In-Reply-To: <bug-26110-12138@http.gcc.gnu.org/bugzilla/>



------- Comment #6 from dg001 at t-online dot de  2006-02-06 20:06 -------
Note, I didn't change the status of the bug yet.
And you are absolutely right about the behavior of fundamental types. But I
still encounter a problem with classes.
Can you explain the behavior of gcc in the following example?

--- BEGIN CODE ---

namespace test {
        template<typename T1> double f(T1 f)
        {
                return 2.;
        }
}

class Type1 {
public:
        Type1()
        {}
        ~Type1()
        {}
};

double f(Type1 f)
{
        return 1.;
}       




int main(int argc, char *argv[]) 
{
        using test::f;

        Type1 d;

        double result1 = f(d);

        double result2 = test::f(d);

        return 0;
}       

--- END CODE ---

class Type1 and the function f are in the global namespace. Nevertheless
"double result1 = f(d);" calls "template<typename T1> double f(T1 f)", which I
think is wrong. The function "double f(Type1 f)" should be called instead.
I tested this with another compiler (MS VC++ 8) and the code of this compiler
calls the global function f in this case.
Which behavior is the right one acording to the standard?

If you now put "class Type1" and and "double f(Type1 f)" in their own namespace
and change the code so it builds again, then gcc produces code, that calls the
function "double f(Type1 f)" when executing the line "double result1 = f(d);". 

Is there anything wrong with the global namespace?


-- 


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


  parent reply	other threads:[~2006-02-06 20:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-05 22:15 [Bug c++/26110] New: " dg001 at t-online dot de
2006-02-05 22:22 ` [Bug c++/26110] " pinskia at gcc dot gnu dot org
2006-02-05 23:14 ` dg001 at t-online dot de
2006-02-05 23:41 ` pinskia at gcc dot gnu dot org
2006-02-06  0:17 ` dg001 at t-online dot de
2006-02-06  0:29 ` pinskia at gcc dot gnu dot org
2006-02-06 20:06 ` dg001 at t-online dot de [this message]
2006-02-06 20:24 ` 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=20060206200640.29035.qmail@sourceware.org \
    --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).