Microsoft KB Archive/241706

= BUG: Compiler Error C2143 on Function-Try-Block Syntax =

Article ID: 241706

Article Last Modified on 7/5/2005

-

APPLIES TO


 * 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 Q241706



SYMPTOMS
The following error messages may appear if you try to use the function-try-block syntax.

error C2143: syntax error : missing ';' before 'try'

error C2143: syntax error : missing ';' before 'try'

error C2065: 'ii' : undeclared identifier

error C2143: syntax error : missing ';' before 'try'

error C2448: 'Unknown' : function-style initializer appears to be a function definition

error C2143: syntax error : missing ';' before 'catch'

error C2143: syntax error : missing ';' before '{'

error C2447: missing function header (old-style formal list?)



CAUSE
The compiler does not support the function-try-block syntax as specified in the C++ Standard (section 15) quoted below:

-3- A function-try-block associates a handler-seq with the ctor-initializer, if present, and the function-body. An exception thrown during the execution of the initializer expressions in the ctor-initializer or during the execution of the function-body transfers control to a handler in a function-try-block in the same way as an exception thrown during the execution of a try-block transfers control to other handler.



STATUS
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
The following code example demonstrates the error: //test.cpp // compiler option needed: /GX int f(int); class C { int i; public: C(int); };

C::C(int ii) try
 * i(f(ii))

{   //  constructor function body } catch (...) {   //  handles exceptions thrown from the ctor-initializer // and from the constructor function body }

Keywords: kbbug kblangcpp kbcpponly kbcompiler KB241706

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.