Microsoft KB Archive/171064: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - "&" to "&") |
||
Line 78: | Line 78: | ||
struct _Tree { | struct _Tree { | ||
_Tree(const int& | _Tree(const int& _Parg) {} | ||
}; | }; | ||
Line 84: | Line 84: | ||
struct set { | struct set { | ||
_Tree _Tr; | _Tree _Tr; | ||
set(const _Pr& | set(const _Pr& _Pred = _Pr()) : _Tr(_Pred) {} | ||
}; | }; | ||
Line 90: | Line 90: | ||
{ | { | ||
Boo(); | Boo(); | ||
set<int>& | set<int>& _xSet; | ||
}; | }; | ||
Revision as of 12:30, 21 July 2020
Article ID: 171064
Article Last Modified on 7/5/2005
APPLIES TO
- Microsoft C++ 32-bit Compiler 1.0
This article was previously published under Q171064
SYMPTOMS
When a member initializer instantiates a template class that takes a const parameter in its constructor, you may receive the following error:
RESOLUTION
Declare a global object of the template class specialization that is used in the member initializer. When optimizations are used, this unreferenced global should be optimized away.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++ version 6.0 for Windows.
MORE INFORMATION
This is a regression from Visual C++ 5.0.
Sample Code
// Compile options needed: none struct _Tree { _Tree(const int& _Parg) {} }; template<class _Pr> struct set { _Tree _Tr; set(const _Pr& _Pred = _Pr()) : _Tr(_Pred) {} }; struct Boo { Boo(); set<int>& _xSet; }; //set<int> x; // uncomment for workaround Boo::Boo() : _xSet(*new set<int>) //C2512 here {}
Additional query words: visual studio service pack
Keywords: kbbug kbfix kbvc600fix KB171064