
BUG: VS.NET template pointer-to-member bug
I found a bug in template parameters and have replicated it:
#include <stdio.h>
class data_t
{
public:
double a;
float b;
Quote:
};
template <class T, double T::* member>
class test_t
{
public:
void test(T *ptr)
{
printf("got: %p\n", &(ptr->*member));
}
Quote:
};
int main(void)
{
test_t<data_t, &data_t::a> t;
data_t d;
printf("should be: %p\n", &d.a);
t.test(&d);
return 0;
Quote:
}
The bug only occurs if the member object is first in the class. The compiler
compiles the template as test_t<data_t, -1>, it should be test_t<data, 0>.
It doesnt make any sense for the member offset to be negative. This bug does
not seem to occur in non templated pointer-to-member operations.
Tested in:
Visual Studio .NET: affected
Visual Studio 6.0: not tested
gcc 3.2: not affected
gcc 2.95.4: not affected
I cant seem to find where to submit bugs so if someone has a better place
than here to submit, let me know.
begin 666 template_bug.cpp
`
end