Microsoft KB Archive/255528

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 13:53, 21 July 2020 by X010 (talk | contribs) (Text replacement - """ to """)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

PSS ID Number: 255528

Article Last Modified on 10/16/2002



The information in this article applies to:

  • Microsoft C/C++ Compiler (CL.EXE)



This article was previously published under Q255528

SYMPTOMS

An access violation may occur if you have a class derived from ostringstream and if this class has a constructor with variable number of arguments.

CAUSE

Incorrect code is generated when the first argument in the variable argument list is a zero.

RESOLUTION

To workaround the problem, use any one of the following three resolutions:

  1. Do not use variable number of arguments for the class constructor.
  2. Let the first argument in the constructor's variable argument list be a non-zero value.
  3. Use a default class constructor with no arguments and then call another member function with a variable argument list.


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

Compile Options : cl /GX test.cpp

//Test.cpp

#include <iostream>
#include <sstream>
using namespace std;

class Test : public ostringstream
{
public:
    Test(bool n,  ...)
    {
    }
};


void main()
{
        cout << "Calling Test " << endl;
        Test my_test1(true, 1); //OK.

        cout << "Calling Test again " << endl;
        Test my_test2(true, 0); //Causes Access Violation  

}

                

Keywords: kbBug kbCPPonly kbSTL KB255528
Technology: kbAudDeveloper kbCVCComp kbVCsearch