_FORTIFY_SOURCE has no effect for C++ due to usage of #define
Cygport now sets _FORTIFY_SOURCE=2 for C and C++ but this has no effect
for C++. In <sys/features.h> __SSP_FORTIFY_LEVEL is always set to 0 if
__cplusplus is defined. This is needed because <ssp/string.h> ... use
#defines to replace the functions.
$ cat copy.c
char sbuf, *dbuf;
void to_sbuf(const char *p)
void to_dbuf(const char *p)
Examine preprocessed code:
$ gcc -D_FORTIFY_SOURCE=2 -O2 -E copy.c > copy2.c
$ vim copy2.c # Remove unnecessary code && pretty-print
Why are these (a ? b : c) expanded from the "#define strcpy" needed?
Both branches lead to the same __builtin___strcpy_chk() call. Is this
possibly needed for (very) old compiler versions with weaker optimization?
According to "gcc -O2 -S" outputs, the generated code is identical for