Many compiler warnings in unit tests when using strict compiler flags #15
Labels
unit-test
Tickets related to the OSAL unit testing (functional and/or coverage)
Milestone
Describe the bug
For historical backward-compatibility reasons ANSI C defines string literals as
char*
type, but these strings are typically put into an.rodata
section on modern processors/linkers, and this section is usually write-protected. If code actually attempts to modify this value, it will generate a segmentation fault and crash.Building with
-Wwrite-strings
causes the compiler to treat string literals asconst char *
instead, thereby generating a warning if passed or assigned to a non-const pointer value.To Reproduce
Configure with
make OSAL_USER_C_FLAGS='-Wall -Werror -std=c99 -pedantic -Wwrite-strings' ENABLE_UNIT_TESTS=true
and observe many warnings generated in the unit test code.Expected behavior
The build should be free of warnings, such that
-Wwrite-strings
can be enabled by default.System observed on:
Ubuntu 18.04 (64-bit)
Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: