BUG: C1001: grammar.c, Line 155, Constructor Argument List

Last reviewed: July 17, 1997
Article ID: Q100966
7.00 7.00a | 1.00 1.50
MS-DOS     | WINDOWS
kbtool kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C/C++ for MS-DOS, versions 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

An attempt to compile, with the optimizing compiler, a class constructor that accepts a variable number of arguments fails and Microsoft C/C++ generates the following message:

   test.cpp(20) : fatal error C1001: INTERNAL COMPILER ERROR
                (compiler file '@(#)grammar.c:1.147', line 155)
                Contact Microsoft Product Support Services

Depending on the complexity of the source code, the error may occur on line 156, 179, or 180 in GRAMMAR.C, rather than on line 155. The error occurs regardless of the specified optimizations.

If the compiler command line includes the /Ox option switch, the following error may occur prior to the C1001 error listed above:

   test.cpp(20) : warning C4713: _aab: INTERNAL COMPILER ERROR;
       restarting (compiler file '@(#)grammar.c:1.147', line 155)
                Contact Microsoft Product Support Services

CAUSE

This error is caused by a problem optimizing the variable argument list in the class constructor. The error occurs only for the actual constructor call (not for the declaration), and occurs only when the number of arguments exceeds a limit that varies depending on the complexity of the code. In the sample code below, the error occurs when the constructor call specifies between 53 and 98 arguments. If the call specifies fewer than 53 arguments, no error occurs. If the call specifies more than 98 arguments, the compiler generates the following warning message:

   test.cpp(20) : fatal error C1035: expression too complex;
      simplify expression

RESOLUTION

To address this situation, perform one of the following two steps:

  • Simplify the code to specify fewer arguments to the constructor. One method to do this involves declaring additional predefined arguments.
  • Specify the /f compiler option switch to call the fast compiler which does not generate this error.

STATUS

Microsoft has confirmed this to be a problem in C/C++ versions 7.0, 7.0a, and 8.0 for MS-DOS. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

This problem does not occur with C/C++ 32-bit compiler versions 8.0 or 9.0, included with Visual 32-bit Edition, versions 1.0 and 2.0, because the /f option is not supported.

MORE INFORMATION

The following code example demonstrates this error when you compile it with the optimizing compiler (using the specified options):

Sample Code

/*
 * Compile options needed: /c /f-
 */

#include <stdarg.h>            // Required for code that uses
                               // variable number of arguments

class N
   {
public:
   N(int ar, ...) {}
   };

static const N title(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 20,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 30,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 40,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 50,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 60,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 70,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 80,
                     1, 2, 3, 4, 5, 6, 7, 8, 9, 90,
                     1, 2, 3, 4, 5, 6, 7, 8
                    );


Additional reference words: 1.00 1.50 7.00 7.00a 8.00 8.00c
KBCategory: kbtool kbbuglist
KBSubcategory: CPPIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.