mirror of
https://github.com/git/git.git
synced 2024-11-27 03:53:55 +08:00
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
71e01a0ebd
commit
d66fe0726b
@ -37,6 +37,7 @@ DEVELOPER_CFLAGS += -Wpointer-arith
|
||||
DEVELOPER_CFLAGS += -Wstrict-prototypes
|
||||
DEVELOPER_CFLAGS += -Wunused
|
||||
DEVELOPER_CFLAGS += -Wvla
|
||||
DEVELOPER_CFLAGS += -Wwrite-strings
|
||||
DEVELOPER_CFLAGS += -fno-common
|
||||
|
||||
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
|
||||
|
Loading…
Reference in New Issue
Block a user