This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
C++ function pointer weirdness
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 22 Feb 2005 10:55:48 +0100 (CET)
- Subject: C++ function pointer weirdness
Yesterday the output of the following program changed
(probably due to the fix for PR19076):
======================================================================
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 - 3.4.0 return 0, GCC 3.4.1 - 3.4.4-20050222 return 2,
and now mainline again returns 0.
So the question is: What is the correct return value?
Btw, we really should have this in the testsuite.
In any case, we have a wrong-code regression here, either on the
3.4 branch or on mainline. But before I open a PR I'd like to sort
out which is the correct behavior.
When the result changed in 3.4.1 I bugged Nathan (who caused this
change) about it, and he claimed that '2' is the correct result.
Intel's compiler indeed returns 2.
Regards,
Volker