257 - _alloca used in prohibited ___location.
Additional Information: Consult MSDN for restrictions on using _alloca in an exception handler.
This warning indicates that _alloca is called from a ___location that does not allow this.
There are restrictions to explicitly calling _alloca in an exception handler (EH). EH routines that run on x86-class processors operate in their own memory frame: They perform their tasks in memory space that is not based on the current ___location of the stack pointer of the enclosing function.
The most common implementations include Windows NT structured exception handling (SEH) and C++ catch clause expressions. Therefore, explicitly calling _alloca in any of the following scenarios results in program failure during the return to the calling EH routine:
- Windows NT SEH exception filter expression: __except ( alloca() )
- Windows NT SEH final exception handler: __finally { alloca() }
- C++ EH catch clause expression
Visual C++ .NET 2002 and later catches the last case as C3204.
Example
Defective Source
char *a
__try {
;
} __except (a = (char *)_alloca(10)) {
;
}
Corrected Source
char *a
a = (char *)malloc(10);
if (a == NULL) {
return;
}
__try {
;
} __except (a) {
;
}
free (a);
Send Feedback on this topic to the authors