Description of problem: Code that previously compiled without warning on f25 gcc 6.3.1 now generates the warning in the summary. Version-Release number of selected component (if applicable): gcc-c++-7.1.1-1.fc26.x86_64 How reproducible: 100% Steps to Reproduce: $ lsb_release -r Release: 25 $ gcc --version gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat << EOF > punning.cpp #include <type_traits> #include <mutex> int main() { std::aligned_storage<sizeof(std::mutex)>::type state_mutex_bytes; new (&state_mutex_bytes) std::mutex; std::mutex& r = *static_cast<std::mutex*>(static_cast<void*>(&state_mutex_bytes)); (void)r; } EOF $ g++ -Wall -O2 -c punning.cpp $ $ lsb_release -r Release: 26 $ gcc --version gcc (GCC) 7.1.1 20170503 (Red Hat 7.1.1-1) Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat << EOF > punning.cpp #include <type_traits> #include <mutex> int main() { std::aligned_storage<sizeof(std::mutex)>::type state_mutex_bytes; new (&state_mutex_bytes) std::mutex; std::mutex& r = *static_cast<std::mutex*>(static_cast<void*>(&state_mutex_bytes)); (void)r; } EOF $ g++ -Wall -O2 -c punning.cpp punning.cpp: In function ‘int main()’: punning.cpp:8:83: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] std::mutex& r = *static_cast<std::mutex*>(static_cast<void*>(&state_mutex_bytes)); ^ Actual results: punning.cpp: In function ‘int main()’: punning.cpp:8:83: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] std::mutex& r = *static_cast<std::mutex*>(static_cast<void*>(&state_mutex_bytes)); Expected results: No warning generated Additional info: I believe this is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 There is also a reproducer in the upstream bug bug I included mine because it is closer to the actual issue seen here, https://copr-be.cloud.fedoraproject.org/results/badone/Ceph-nightlies/fedora-26-x86_64/00546644-ceph/build.log.gz
I created a test package here https://copr-be.cloud.fedoraproject.org/results/badone/misc/fedora-26-x86_64/00557857-gcc/ which includes the patch for pr80593 and can confirm it allows both the test case and the original ceph (rocksdb) code to build successfully without this warning.
*** Bug 1463739 has been marked as a duplicate of this bug. ***
Jakub, any chance we can get the patch for this into the F26 package until it gets synched up to mainline? It's kind of a hinderance for building ceph at the moment.
Should be fixed now.