Microsoft KB Archive/255528

From BetaArchive Wiki

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


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.


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


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.


Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.


Steps to Reproduce Behavior

Compile Options : cl /GX test.cpp


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

class Test : public ostringstream
    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