Compiler Warning (level 3) C4748
/GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
/GS (Buffer Security Check), which is enabled by default, cannot protect parameters and local variables from local buffer overrun in a function unless the function has optimizations enabled.
The compiler will disable optimizations if a function has inline assembly code containing flow of control (jmp or jcc, for example) statements.
Enable optimizations to resolve this warning, and to allow /GS to protect parameters and local variables from local buffer overrun.
Example
The following sample generates C4748.
// C4748.cpp
// compile with: /O2 /W3
#include <string.h>
#include <stdlib.h>
#pragma optimize("", off)
void f(const char *str) { // C4748 warning
char buf[100];
strcpy_s(buf, _countof(buf), str);
}
#pragma optimize("", on)
int main() {
f("aa");
}