VC7 bug: static member templates 
Author Message
 VC7 bug: static member templates

The following code does not compile under VC7, it should.

class X
{
public:
 template <typename T>
  static void f(int) { }

 typedef void (*pf)(int);

 void g(pf) {};

 void h()
 {
  g(f<int>);    // 1
 }

Quote:
};

VC7 complains (at //1) that f<int> cannot be converted to X::pf (aka void
(*)(int)), which it clearly can be.  Apparently VC7 ignores the static
keyword when used with a member template function - a combination which
should be legal according to the standard.

-cd



Tue, 17 Aug 2004 05:30:18 GMT  
 VC7 bug: static member templates

Quote:
> class X
> {
> public:
>  template <typename T>
>   static void f(int) { }

>  typedef void (*pf)(int);

>  void g(pf) {};

>  void h()
>  {
>   g(f<int>);    // 1
>  }
> };

Comeau and Sun Workshop both compile this with out any problems. Looks
like another bug.


Tue, 17 Aug 2004 05:41:42 GMT  
 VC7 bug: static member templates
Carl: this is a bug in the Visual C++ 7.0 compiler. I have added it to our
bug database and we will endeavor to have it fixed in the next release.

Thanks for taking the time to report this issue.

--
Jonathan Caves
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> The following code does not compile under VC7, it should.

> class X
> {
> public:
>  template <typename T>
>   static void f(int) { }

>  typedef void (*pf)(int);

>  void g(pf) {};

>  void h()
>  {
>   g(f<int>);    // 1
>  }
> };

> VC7 complains (at //1) that f<int> cannot be converted to X::pf (aka void
> (*)(int)), which it clearly can be.  Apparently VC7 ignores the static
> keyword when used with a member template function - a combination which
> should be legal according to the standard.

> -cd



Tue, 17 Aug 2004 06:03:07 GMT  
 VC7 bug: static member templates


Quote:
> Carl: this is a bug in the Visual C++ 7.0 compiler. I have added it to our
> bug database and we will endeavor to have it fixed in the next release.

That's all I can ask :)

Quote:

> Thanks for taking the time to report this issue.

Anytime.  Thanks for taking the time to record it.  The only thing worse
than bugs is bugs that don't get fixed 'cause no one bothered to report
them.

-cd



Tue, 17 Aug 2004 06:12:21 GMT  
 VC7 bug: static member templates
It gets better when you explicitly write g(X::f<i>):

fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'f:\vs70builds\9466\vc\Compiler\CxxFE\sl\p1\Cxx\grammar.y',
line 9326)


Quote:
> The following code does not compile under VC7, it should.

> class X
> {
> public:
>  template <typename T>
>   static void f(int) { }

>  typedef void (*pf)(int);

>  void g(pf) {};

>  void h()
>  {
>   g(f<int>);    // 1
>  }
> };

> VC7 complains (at //1) that f<int> cannot be converted to X::pf (aka void
> (*)(int)), which it clearly can be.  Apparently VC7 ignores the static
> keyword when used with a member template function - a combination which
> should be legal according to the standard.

> -cd



Tue, 17 Aug 2004 07:19:46 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. static member objects of templates - bug?

2. Bug in inheritance from template template parameters in VC7

3. BUG: VS.NET template pointer-to-member bug

4. Member templates in VC7?

5. VC7.1 C++ bug: incorrect definition of the constructor of a template accepted

6. template classes with static members

7. Static members in Templates

8. static data member of template class

9. Initialization of static data member of template class

10. template classes with static members

11. Static member definition of template class fails

12. Static member definition of template class fails

 

 
Powered by phpBB® Forum Software