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

Reply via email to