https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65896
Bug ID: 65896 Summary: Erroneous uninitialized variable access error in constexpr function with temporary variables Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: david at doublewise dot net Target Milestone: --- file.cpp ================================================== struct base{}; struct derived : base { constexpr derived(): base{}, m_value(0) { } constexpr derived(derived & other): base{}, m_value(other) { } constexpr explicit operator int() const { return m_value; } int m_value; }; constexpr int by_ref(derived && value) { return (derived(value), 0); } constexpr int value = by_ref(derived{}); ================================================== c++ -std=c++11 -o /dev/null file.cpp -c gcc 4.8.3 and 4.9.3 and clang 3.5.0 successfully compile this program. gcc 5.1.1 fails with: file.cpp:22:29: in constexpr expansion of ‘by_ref(derived())’ file.cpp:22:39: in constexpr expansion of ‘derived((* & value))’ file.cpp:10:16: in constexpr expansion of ‘(& other)->derived::operator int()’ file.cpp:22:39: error: accessing uninitialized member ‘derived::m_value’ constexpr int value = by_ref(derived{}); ^ Changing to C++1y / C++14 does not change this.