[Bug c++/20966] New: [4.0/4.1 regression] cv-qualified function references and overload resolution

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Apr 12 11:10:00 GMT 2005


Consider the following program:

====================================================================
template <typename T> int ref (T&)                { return 0; }
template <typename T> int ref (const T&)          { return 1; }
template <typename T> int ref (const volatile T&) { return 2; }
template <typename T> int ref (volatile T&)       { return 4; }

template <typename T> int ptr (T*)                { return 0; }
template <typename T> int ptr (const T*)          { return 8; }
template <typename T> int ptr (const volatile T*) { return 16; }
template <typename T> int ptr (volatile T*)       { return 32; }

void foo() {}

int main()
{
    return ref(foo) + ptr(&foo);
}
====================================================================

GCC 2.95.3 through 3.4.0 return 0, GCC 3.4.1 through 3.4.3 return 2.
But the 4.0 branch and mainline again return 0.

The current reading of the standard suggests that 2 is indeed the correct
answer (quoting Gaby: In summary, cv-qualifiers although ignored and void
of semantics for function types, do actually play a significant role in
"winning" the partial ordering tournoi, and after that disappear.)

Hence, we have a wrong-code bug in 4.0 branch and mainline.

However, since the situation between pointers and references is unsymmetric
in this case, Gaby is going to raise the issue in the core language list.

So, I'm suspending this until we have a definite answer.

See also http://gcc.gnu.org/ml/gcc/2005-02/msg00834.html

-- 
           Summary: [4.0/4.1 regression] cv-qualified function references
                    and overload resolution
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,gdr at integrable-
                    solutions dot net


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



More information about the Gcc-bugs mailing list