From 5df7bb9f2a5853c218a2dc28e32564eba10f4fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 26 Jan 2021 13:22:07 +0100 Subject: [PATCH] Disable strict pointer aliasing I'm not really a C-level language lawyer, but the way how the code routinely uses two differently-types pointers to access the same object is undefined behavior in C. Just having "the same layout" of individual struct members [does not make these types compatible](https://en.cppreference.com/w/c/language/type#Compatible_types), and that means that it is necessary to disable [strict aliasing](https://en.cppreference.com/w/c/language/object#Strict_aliasing) rules in the whole of libyang, as far as I can tell. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dff15c54..c6ba361dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE debug) endif() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=gnu99") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=gnu99 -fno-strict-aliasing") set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_C_FLAGS_PACKAGE "-g -O3 -DNDEBUG") set(CMAKE_C_FLAGS_DEBUG "-g -Og")