This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21895] New: [wrong-code] template class member function with array typedef arguement behaves erroneously
- From: "leventyilmaz at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Jun 2005 23:25:39 -0000
- Subject: [Bug c++/21895] New: [wrong-code] template class member function with array typedef arguement behaves erroneously
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here is a sample code that generates the problem (tried to reduce it as much as
possible):
#include<iostream>
template<class T>
class Bar
{
public:
void foo(T a) { std::cout << a << std::endl; }
};
int main()
{
typedef int arr[3];
arr sz={0,1,2};
std::cout << sz << std::endl; // prints address of sz[0]
Bar<arr>().foo(sz); // prints another address!!
return 0;
}
Note:
Everything works fine and this erroneous behaviour is NOT observed if
- foo is a non-member template function:
template<class T> void foo(T);
- foo is a member function with non-generic arguement:
typedef int arr[3];
template<class T> void Bar<T>::foo(arr a);
- foo is exact same as the code above (member func with generic arguement) but
the arguement is a reference rather that pass by value
template<class T> void Bar<T>::foo(T& a);
--
Summary: [wrong-code] template class member function with array
typedef arguement behaves erroneously
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: leventyilmaz at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21895