FIX: Incorrect Template Declaration Causes Compiler Hang

Last reviewed: September 18, 1997
Article ID: Q121015
2.00 WINDOWS NT kbtool kbfixlist kbcode

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE) included with: Microsoft Visual C++, 32-bit Edition, version 2.0

SYMPTOMS

The compiler may hang (stop processing) when compiling a template that includes a syntax error in the function declaration as shown in the samples in this article.

RESOLUTION

Press CTRL+BREAK to stop the build process and return the focus to Visual C++. Correcting the syntax error will allow the code to compile.

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 Microsoft Visual C++, 32-bit Edition, version 4.0.

MORE INFORMATION

The following samples can be used to reproduce the problem:

Sample Code 1

/* Compile options needed: none
*/

template <class T>

T max(T a, T b>    // Note: ">" on right should be a ")"
    {
    return a;
    }

void main () {}

Sample Code 2

/* Compile options needed: none
*/

template<class TYPE, class ARG_TYPE> class CList { public:
    TYPE* GetHead (void);
};

//
//   SYNTAX ERROR: "TYPE(" instead of "TYPE*"
//
template<class TYPE, class ARG_TYPE> inline TYPE( CList<TYPE, ARG_TYPE>::GetHead (void) { }


Additional reference words: 2.00 9.00 hang lock-up freeze
KBCategory: kbtool kbfixlist kbbuglist kbcode
KBSubcategory: CPPIss
Keywords : CPPIss kbbuglist kbcode kbfixlist kbtool
Version : 2.00
Platform : NT WINDOWS
Solution Type : kbfix


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: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.