Skip to content

Commit

Permalink
Disable strict pointer aliasing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jktjkt committed Jan 26, 2021
1 parent 2f717b6 commit 5df7bb9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 5df7bb9

Please sign in to comment.