BUG: VS.NET template pointer-to-member bug 
Author Message
 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



Mon, 03 Oct 2005 03:34:52 GMT  
 BUG: VS.NET template pointer-to-member bug


Fri, 19 Jun 1992 00:00:00 GMT  
 BUG: VS.NET template pointer-to-member bug

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

It appears to be fixed in VS.NET 2003 (official release date is next week -
April 24).

Quote:

> I cant seem to find where to submit bugs so if someone has a better
> place than here to submit, let me know.

This newsgroup is usually sufficient.

-cd



Mon, 03 Oct 2005 03:50:11 GMT  
 BUG: VS.NET template pointer-to-member bug
Can't reproduce under VC7.1 RC3. Apparently, it's fixed in the upcoming
release, due out on Apr 24
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I found a bug in template parameters and have replicated it:
> #include <stdio.h>

> class data_t
> {
> public:
> double a;
> float b;
> };

> template <class T, double T::* member>
> class test_t
> {
> public:
> void test(T *ptr)
> {
> printf("got: %p\n", &(ptr->*member));
> }
> };

> 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;
> }
> 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.



Mon, 03 Oct 2005 03:51:17 GMT  
 BUG: VS.NET template pointer-to-member bug


Fri, 19 Jun 1992 00:00:00 GMT  
 BUG: VS.NET template pointer-to-member bug

Quote:

>I found a bug in template parameters and have replicated it:
>#include <stdio.h>

>class data_t
>{
>public:
>    double a;
>    float b;
>};

>template <class T, double T::* member>
>class test_t
>{
>public:
>    void test(T *ptr)
>    {
>            printf("got: %p\n", &(ptr->*member));
>    }
>};

>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;
>}
>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.

It appears this problem was fixed in VC 7.1, already downloadable
by MSDN Universal subscribers and due for general release very soon.

--
Doug Harrison
Microsoft MVP - Visual C++



Mon, 03 Oct 2005 03:50:40 GMT  
 BUG: VS.NET template pointer-to-member bug


Fri, 19 Jun 1992 00:00:00 GMT  
 BUG: VS.NET template pointer-to-member bug
Can't slip much past the VC++ MVPs!  3 (nearly identical) replies within 1
minute :)

-cd



Mon, 03 Oct 2005 04:09:34 GMT  
 BUG: VS.NET template pointer-to-member bug

Quote:
> Can't slip much past the VC++ MVPs!  3 (nearly identical) replies within 1
> minute :)

  Great!
  (Is Igor an MVP, too?)

Quote:
> -cd

  Schobi

--

I'm Schobi at suespammers org



Mon, 03 Oct 2005 16:47:29 GMT  
 BUG: VS.NET template pointer-to-member bug

Quote:


>> Can't slip much past the VC++ MVPs!  3 (nearly identical) replies
>> within 1 minute :)

>   Great!
>   (Is Igor an MVP, too?)

Oh yeah! See
http://mvp.support.microsoft.com/default.aspx?scid=fh;EN-US;mvpaward&...
oc#faq1182.

-cd



Mon, 03 Oct 2005 21:37:59 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Bug with explicit function template instantiation in VS.NET

2. Bug with template member functions.

3. VC7 bug: static member templates

4. template member specialization bug?

5. C2660 with template member function: Compiler bug?

6. VC++ 4.2 MFC - Possible bug in the Copy member function of a CArray template

7. static member objects of templates - bug?

8. Reporting bugs to the net (was Re: Another bug in DEC Fortran)

9. pointer to member bug?

10. Potential VC++ 5 bug - pointer to member as constructor argument

11. Bug (?) in VC 4.2: pointer to data member

12. BUG: pointer to __fastcall function as template parameter

 

 
Powered by phpBB® Forum Software