Article ID: 241592
Article Last Modified on 10/24/2003
APPLIES TO
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Professional Edition
This article was previously published under Q241592
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 that this is a bug in the Microsoft products that are 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.
Keywords: kbbug KB241592