Article ID: 259244
Article Last Modified on 7/5/2005
APPLIES TO
- Microsoft C++ 32-bit Compiler 1.0
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
This article was previously published under Q259244
SYMPTOMS
When a function that expects STL::string as a reference is passed as an input argument to the __assume function, you may get the following error message:
Please refer to the "More Information" section for the sample code that reproduces the problem.
RESOLUTION
Use one of the following two methods to work around this problem:
- Construct a temporary STL::string object and pass this object as a reference to the function (see workaround 1 in the sample code).
- Introduce a temporary variable to store the return value of the function, which expects STL::string as reference (see workaround 2 in the sample code).
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
Steps to Reproduce Behavior
The following sample code, when compiled, reproduces the problem. Uncomment the #define statements depending upon which workaround you choose:
// repro.cpp // cl /Gx /c repro.cpp #include <string> //#define WORK_AROUND_1 //#define WORK_AROUND_2 using namespace std; int MyFunc(string &m_str) { return 1; } int main() { string str ; int temp; __assume(MyFunc(string())); // This line generates C1001 error. // Workaround 1: Call the function with a temporary STL string object. #ifdef WORK_AROUND_1 __assume(MyFunc(str)); #endif // Workaround 2: Store the return value of function in a temporary variable #ifdef WORK_AROUND_2 temp = MyFunc(string()); __assume(temp); #endif return 1; }
Keywords: kbbug kbnofix KB259244