unreported bug with default template parameter 
Author Message
 unreported bug with default template parameter

Hi,

the following applies to VC++ 6 SP4
the below code has a compile error C2065: 'B' : undeclared identifier
pointing to the function declaration.
If I take the default value ' B() ' away it compiles no problem.
It also compiles if the template function is not embedded in a class.
I could not find any info on this bug in msdn.
This code compiles without problems on other C++ compilers.

class Err
{
.......

template <class A, class B>
void push(const ErrMsgID aErrMsgID, const A& aFirstAddOn, const B& aSecondAddOn =
B())
{const B test = aSecondAddOn;};

.......

Quote:
}

Claus


Tue, 02 Sep 2003 19:18:26 GMT  
 unreported bug with default template parameter

Quote:

> Hi,

> the following applies to VC++ 6 SP4
> the below code has a compile error C2065: 'B' : undeclared identifier
> pointing to the function declaration.
> If I take the default value ' B() ' away it compiles no problem.
> It also compiles if the template function is not embedded in a class.
> I could not find any info on this bug in msdn.
> This code compiles without problems on other C++ compilers.

> class Err
> {
> .......

> template <class A, class B>
> void push(const ErrMsgID aErrMsgID, const A& aFirstAddOn, const B& aSecondAddOn =
> B())
> {const B test = aSecondAddOn;};

> .......

> }

Can you explain why you're trying to do this?

If you call

Err e;
ErrMsgID  i;

e.push (i, 10);

How is the compiler supposed to make out what is the type of B?

If you call:

// Specify B here

e.template push <int, int> (i, 10);

you might as well write

e.template push <int, int> (i, 10, int ());

// Warning: untested with VC++

Regards
Sai



Thu, 04 Sep 2003 14:06:13 GMT  
 unreported bug with default template parameter


Fri, 19 Jun 1992 00:00:00 GMT  
 unreported bug with default template parameter
Hi,

it will be an incomplete type. This could cause runtime problems when referencing
the class, but IMHO should compile relating to the standard.

The following does not have this problem and also does not compile:

template <class B>
inline void push(const ErrMsgID aErrMsgID, const B& aFirstAddOn, const B&
aSecondAddOn = B())
{const B test = B();};

Claus

Quote:
-----Original Message-----


> Hi,

> the following applies to VC++ 6 SP4
> the below code has a compile error C2065: 'B' : undeclared identifier
> pointing to the function declaration.
> If I take the default value ' B() ' away it compiles no problem.
> It also compiles if the template function is not embedded in a class.
> I could not find any info on this bug in msdn.
> This code compiles without problems on other C++ compilers.

> class Err
> {
> .......

> template <class A, class B>
> void push(const ErrMsgID aErrMsgID, const A& aFirstAddOn, const B& aSecondAddOn
=
> B())
> {const B test = aSecondAddOn;};

> .......

> }

Can you explain why you're trying to do this?

If you call

Err e;
ErrMsgID  i;

e.push (i, 10);

How is the compiler supposed to make out what is the type of B?

If you call:

// Specify B here

e.template push <int, int> (i, 10);

you might as well write

e.template push <int, int> (i, 10, int ());

// Warning: untested with VC++

Regards
Sai
.



Fri, 05 Sep 2003 17:52:41 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. template template parameter with default value (VS.NET 2003)

2. VC 7.1 final beta: bug with template template parameters

3. Possible bug with template template parameters in VC++ 7.0

4. Bug in inheritance from template template parameters in VC7

5. VC7 does NOT support template-template parameters involving non-type parameters

6. Template argument dependant default parameter

7. WORKAROUND: nested template type default parameter values

8. Default Template Parameters

9. Values as template parameters (compiler bug?)

10. BUG: pointer to __fastcall function as template parameter

11. function parameters: default value, optional parameter

12. template-template params default values - std::deque

 

 
Powered by phpBB® Forum Software