DOCUMENT:Q241592 07-MAY-2001 [visualc] TITLE :BUG: Compiling with the In-Line Function Expansion Optimizations PRODUCT :Microsoft C Compiler PROD/VER:WINDOWS:6.0; winnt:6.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual C++, 32-bit Enterprise Edition, version 6.0 - Microsoft Visual C++, 32-bit Professional Edition, version 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== The Visual C++ compiler fails to generate a C4716 error message when compiling a nonvoid member function without a return statement with the /Ob1 or /Ob2 optimization. Note that this problem happens only when the class member function is defined within the class definition. Placing the nonvoid member function outside the class definition and marking it with the __inline keyword also fails to generate the error message. RESOLUTION ========== To resolve this problem, use one of the following two resolutions: - Do not use the compiler optimizations __inline(/Ob1) or Any Suitable(/Ob2). - Place the member function definition outside the class definition. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- The following code demonstrates the problem: class A { public: A( void ) { m_i = 0; } int increment(void); private: int m_i; }; __inline int A::increment( void ) { m_i++; } void main(void) { int i = 0; A a; i = a.increment(); } Compile the code with Only __inline(/Ob1) or Any Suitable(/Ob2) optimizations. Additional query words: ====================================================================== Keywords : Technology : kbVCsearch kbAudDeveloper kbVC600 kbVC32bitSearch Version : WINDOWS:6.0; winnt:6.0 Issue type : kbbug ============================================================================= 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. Copyright Microsoft Corporation 2001.