Skip to content

Commit 7857c99

Browse files
committed
Clarify -Werror=implicit -Werror=incompatible-pointer-types -Werror=int-conversion only apply for C code
Signed-off-by: Thomas Nyman <[email protected]>
1 parent c73194c commit 7857c99

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ When compiling C or C++ code on compilers such as GCC and clang, turn on these f
4242
| for x86_64 | `-fcf-protection=full` |
4343
| for aarch64 | `-mbranch-protection=standard` |
4444
| for production code | `-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero` |
45-
| for treating obsolete C constructs as errors | `-Werror=implicit -Werror=incompatible-pointer-types -Werror=int-conversion` |
45+
| for C code treating obsolete C constructs as errors | `-Werror=implicit -Werror=incompatible-pointer-types -Werror=int-conversion` |
4646
| for multi-threaded C code using GNU C library pthreads | `-fexceptions` |
4747
| during development but *not* when distributing source | `-Werror` |
4848

@@ -500,7 +500,7 @@ Some Linux distributions, such as Arch Linux[^arch-buildflags], Fedora[^fedora-f
500500

501501
#### Synopsis
502502

503-
Make the compiler treat obsolete C constructs as errors.
503+
Make the compiler treat obsolete C constructs as errors. These options are relevant for C code only.
504504

505505
The ISO/IEC 9899:1999 standard, commonly referred to as C99, removed several backwards compatibility features, such as implicit function declarations and implicit return types from the C language. Similarly, the earlier C89/C90 standard (ANSI X3.159-1989 / ISO/IEC 9899:1990) removed certain implicit type conversion, such as implicit conversions from integer to pointer types. Such implicit declarations[^DCL31-C] and type conversions (whether implicit or explicit[^INT36-C]) can be considered dangerous for the correctness and security of C code as they lead to less stringent type checking and may rely on implementation-defined behavior. However, modern compilers still accept these obsolete constructs by default unless instructed to pedantically give errors whenever the base standard requires them.
506506

0 commit comments

Comments
 (0)