Skip to content

Commit 319e903

Browse files
Fix description of fallthrough. Fixes #478
Signed-off-by: David A. Wheeler <[email protected]>
1 parent ffcaa70 commit 319e903

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ This warning flag warns when a fallthrough occurs unless it is specially marked
320320

321321
This warning flag does not have a performance impact. However, sometimes a fallthrough *is* intentional. This flag requires developers annotate those (rare) cases in the source code where a fallthrough *is* intentional, to suppress the warning. Obviously, this annotation should *only* be used when it is intentional. C++17 (or later) code should simply use the attribute `[[fallthrough]]` as it is standard (remember to add `;` after it).
322322

323-
The C17 standard[^C2017] does not provide a mechanism to mark intentional fallthroughs. Different tools support different mechanisms for marking one, including attributes and comments in various forms[^Shafik15]. A portable way to mark one is to define a function-like macro named `fallthrough()` to mark an intentional fallthrough that adjusts to the relevant tool (e.g., compiler) mechanism:
323+
The C17 standard[^C2017] does not provide a mechanism to mark intentional fallthroughs. Different tools support different mechanisms for marking one, including attributes and comments in various forms[^Shafik15]. A portable way to mark one is to define a function-like macro named `fallthrough()` to mark an intentional fallthrough that adjusts to the relevant tool (e.g., compiler) mechanism. We suggest using this construct below, inspired by the keyword-like construct used by the Linux kernel version 5.10 and later. We suggest using a function call syntax instead so more editors and other tools will deal with it correctly:
324324

325325
~~~c
326326
#if __has_attribute(__fallthrough__)

0 commit comments

Comments
 (0)