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

Compiler Warning C4750

Visual Studio 2005

Error Message

'identifier': function with _alloca() inlined into a loop

The 'identifier' function forces inline expansion of the _alloca function within a loop, which might cause a stack overflow when the loop is executed.

To correct this error

  1. Ensure that the 'identifier' function is not modified with the __forceinline specifier.

  2. Ensure that the 'identifier' function does not contain a _alloca function that is contained in a loop.

  3. Do not specify the /O1, /O2, /Ox, or /Og compilation switch.

  4. Place the _alloca function in a try-except statement that will catch a stack overflow.

Example

The following code example calls MyFunction in a loop, and MyFunction calls the _alloca function. The __forceinline modifier causes the inline expansion of the _alloca function.

// c4750.cpp
// compile with: /O2 /W2 /c
#include <intrin.h>

char * volatile newstr;

__forceinline void myFunction(void) // C4750
{
// The _alloca function does not require a __try/__except 
// block because the example uses compiler option /c.
    newstr = (char * volatile) _alloca(1000);
}

int main(void)
{
    for (int i=0; i<50000; i++)
       myFunction();
    return 0;
}

Community Additions

ADD
Show:
© 2015 Microsoft