Skip to content

Commit a762851

Browse files
committed
Added '-fno-delete-null-pointer-checks' to GCC compilation options
From Adam Green, regarding using -fno-delete-null-pointer-checks: "I would argue that on Cortex-M processors, it is more dangerous to not have it. The compiler can actually generate incorrect code because it is making an incorrect assumption (that reads from a NULL pointer will throw an exception.) The GCC for ARM developers should actually never enable the delete-null-pointer-checks optimization for Cortex-M processors. There is a comment in the GCC manual that indicates, "Some targets, especially embedded ones, disable this option [delete-null-pointer-checks] at all levels." Not having this flag is pretty risky on the current versions of GCC_ARM. Just to clarify, this flag doesn't enable an optimization...it disables an unsafe optimization."
1 parent 73b1687 commit a762851

File tree

1 file changed

+1
-1
lines changed
  • workspace_tools/toolchains

1 file changed

+1
-1
lines changed

workspace_tools/toolchains/gcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, target, options=None, notify=None, tool_path=""):
5050
common_flags = ["-c", "-O2", "-Wall",
5151
"-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
5252
"-ffunction-sections", "-fdata-sections",
53-
"-MMD"
53+
"-MMD", "-fno-delete-null-pointer-checks",
5454
] + self.cpu
5555

5656
if "save-asm" in self.options:

0 commit comments

Comments
 (0)