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
Subject: Re: 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> writes: | 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. I just spoke to John Spicer before lunch, and he told me there is an open issue for that. I'll give you the number as soon as he gave it to me. -- Gaby
It's DR 503.
The fix of PR 28385 changed the behavior on mainline so that the bug is now fixed on mainline (w.r.t. current version of the standard). I.e. only the 4.0 branch and the 4.1 branch (and everyting before 3.4.1) is affected.
This is ok in the current release branches.