Skip to content

Commit d66fe07

Browse files
pks-tgitster
authored andcommitted
config.mak.dev: enable -Wwrite-strings warning
Writing to string constants is undefined behaviour and must be avoided in C. Even so, the compiler does not help us with this by default because those constants are not in fact marked as `const`. This makes it rather easy to accidentally assign a constant to a non-const variable or field and then later on try to either free it or write to it. Enable `-Wwrite-strings` to catch such mistakes. With this warning enabled, the type of string constants is changed to `const char[]` and will thus cause compiler warnings when being assigned to non-const fields and variables. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71e01a0 commit d66fe07

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

config.mak.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ DEVELOPER_CFLAGS += -Wpointer-arith
3737
DEVELOPER_CFLAGS += -Wstrict-prototypes
3838
DEVELOPER_CFLAGS += -Wunused
3939
DEVELOPER_CFLAGS += -Wvla
40+
DEVELOPER_CFLAGS += -Wwrite-strings
4041
DEVELOPER_CFLAGS += -fno-common
4142

4243
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)

0 commit comments

Comments
 (0)