Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence type punning warning reported by gcc 6.5 #35849

Merged
merged 2 commits into from
Dec 4, 2019

Conversation

kevingranade
Copy link
Member

Summary

SUMMARY: None

Purpose of change

Travis builds under GCC 6.5 have been failing due to a type punning warning.
https://travis-ci.org/CleverRaven/Cataclysm-DDA/jobs/619431840

Describe the solution

Silence this class of warnings when building under anything from the GCC 6 family.

Describe alternatives you've considered

There are new versions of colony that may have addressed this, but I don't want to re-import right now.

Testing

Ideally reproduce and test this on a GCC 6.5 system, but IDK how straightforward that will be.

Additional context

Text of the warning:

In file included from colony_test.cpp:8:0:
../src/colony.h: In instantiation of ‘void cata::colony<element_type, element_allocator_type, element_skipfield_type>::fill_skipblock(const element_type&, cata::colony<element_type, element_allocator_type, element_skipfield_type>::aligned_pointer_type, cata::colony<element_type, element_allocator_type, element_skipfield_type>::skipfield_pointer_type, cata::colony<element_type, element_allocator_type, element_skipfield_type>::skipfield_type) [with element_type = int; element_allocator_type = std::allocator; element_skipfield_type = short unsigned int; cata::colony<element_type, element_allocator_type, element_skipfield_type>::aligned_pointer_type = std::aligned_storage<4ul, 4ul>::type*; cata::colony<element_type, element_allocator_type, element_skipfield_type>::skipfield_pointer_type = short unsigned int*; cata::colony<element_type, element_allocator_type, element_skipfield_type>::skipfield_type = short unsigned int]’:

../src/colony.h:1555:43: required from ‘void cata::colony<element_type, element_allocator_type, element_skipfield_type>::insert(cata::colony<element_type, element_allocator_type, element_skipfield_type>::size_type, const element_type&) [with element_type = int; element_allocator_type = std::allocator; element_skipfield_type = short unsigned int; cata::colony<element_type, element_allocator_type, element_skipfield_type>::size_type = long unsigned int]’

colony_test.cpp:689:39: required from here

../src/colony.h:1463:34: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]

                              *( reinterpret_cast<aligned_pointer_type>( &aligned_copy ) ) );

                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@kevingranade kevingranade requested a review from ifreund December 4, 2019 03:21
@kevingranade kevingranade added [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments labels Dec 4, 2019
@ZhilkinSerg ZhilkinSerg merged commit 940cf72 into master Dec 4, 2019
I-am-Erk pushed a commit to I-am-Erk/Cataclysm-DDA that referenced this pull request Dec 6, 2019
@kevingranade kevingranade deleted the kevingranade-silence-type-punning-warning branch December 16, 2019 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants