In the program:
--------------
extern "C" int puts(const char*);

template<typename A, typename B>
void foo(A a, B b)
{
    puts("ERROR: foo<A, B>");
}

template<typename X>
void bar(X a)
{
#ifdef ERROR
    ::foo(a, a);
#else
    foo(a, a);
#endif
}

template<typename A>
void foo(A a, A b)
{
    puts("OK: foo<A>");
}

int main()
{
    int a = 0;
    bar(a);
}
---------------
When foo<> template is accessed without namespace qualifier from within bar<>
template, GCC selects correct second variant of template variant.
If I put namespace qualifier gcc chooses the first variant.
This bug appeared with gcc 3.4 and exists in 3.4.1-3.4.3.
I didn't check newer versions.
There was no this bug in gcc 2.95-3.3.3.
Intel, Sun, and MS compilers all choose correct second variant of foo<>.

-- 
           Summary: template resolution is wrong when accessed with
                    namespace prefix
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vasilche at ncbi dot nlm dot nih dot gov
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 3.4.0-3.4.3
  GCC host triplet: Linux widget1 2.4.23-P4-4G #8 SMP Tue Dec 16 16:34:15
                    EST 2003 i


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

Reply via email to