Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning (level 1) C4717

'function' : recursive on all control paths, function will cause runtime stack overflow

Every path through a function contains a call to the function. Since there is no way to exit the function without first calling itself recursively, the function will never exit.

The following sample generates C4717:

// C4717.cpp
// compile with: /W1 /c
// C4717 expected
int func(int x) {
   if (x > 1)
      return func(x - 1); // recursive call
   else {
      int y = func(0) + 1; // recursive call
      return y;
   }
}

int main(){
   func(1);
}

Community Additions

ADD
Show:
© 2015 Microsoft