Compiler Warning (level 3) C4748
TOC
Collapse the table of content
Expand the table of content
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. ArchiveDisclaimer

Compiler Warning (level 3) C4748

Error Message

/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");
}
Show:
© 2016 Microsoft