From 105785cad74a4ac5d3319b445c9f78438d455b06 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sep 15 2020 13:38:04 +0000 Subject: Fix uninitialized variable caught by gcc-11. Fix dynamic casts to avoid gcc-11 diagnostic --- diff --git a/cataclysm-dda-gcc11.patch b/cataclysm-dda-gcc11.patch new file mode 100644 index 0000000..fa01209 --- /dev/null +++ b/cataclysm-dda-gcc11.patch @@ -0,0 +1,61 @@ +diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp +index 0b59272..a7dc11e 100644 +--- a/src/activity_item_handling.cpp ++++ b/src/activity_item_handling.cpp +@@ -1146,7 +1146,7 @@ static activity_reason_info find_base_construction( + + //we can't immediately build it, looking for pre-req + used.insert( idx ); +- cata::optional reason; ++ cata::optional reason = { }; + construction_id pre_req_idx( -1 ); + //first step: try only constructions with the same description + //second step: try all constructions +diff --git a/src/avatar.cpp b/src/avatar.cpp +index 6c17505..4d33e34 100644 +--- a/src/avatar.cpp ++++ b/src/avatar.cpp +@@ -416,7 +416,7 @@ bool avatar::read( item &it, const bool continuous ) + // special guidebook effect: print a misc. hint when read + if( reader != this ) { + add_msg( m_info, fail_messages[0] ); +- dynamic_cast( reader )->say( get_hint() ); ++ dynamic_cast( *reader ).say( get_hint() ); + } else { + add_msg( m_info, get_hint() ); + } +diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp +index 1a7149c..728e51d 100644 +--- a/src/avatar_action.cpp ++++ b/src/avatar_action.cpp +@@ -595,7 +595,7 @@ void avatar_action::autoattack( avatar &you, map &m ) + if( !c->is_npc() ) { + return false; + } +- return !dynamic_cast( c )->is_enemy(); ++ return !dynamic_cast( *c ).is_enemy(); + } ), critters.end() ); + if( critters.empty() ) { + add_msg( m_info, _( "No hostile creature in reach. Waiting a turn." ) ); +diff --git a/src/item.cpp b/src/item.cpp +index 635b56c..194df4d 100644 +--- a/src/item.cpp ++++ b/src/item.cpp +@@ -7799,13 +7799,13 @@ units::volume item::get_total_capacity() const + // future then this probably warrants a new method on use_function to + // access this information generically. + if( is_bandolier() ) { +- result += dynamic_cast +- ( type->get_use( "bandolier" )->get_actor_ptr() )->max_stored_volume(); ++ result += dynamic_cast ++ ( *type->get_use( "bandolier" )->get_actor_ptr() ).max_stored_volume(); + } + + if( is_holster() ) { +- result += dynamic_cast +- ( type->get_use( "holster" )->get_actor_ptr() )->max_stored_volume(); ++ result += dynamic_cast ++ ( *type->get_use( "holster" )->get_actor_ptr() ).max_stored_volume(); + } + + return result; diff --git a/cataclysm-dda.spec b/cataclysm-dda.spec index f3c7a21..75f00b7 100644 --- a/cataclysm-dda.spec +++ b/cataclysm-dda.spec @@ -8,12 +8,13 @@ Name: cataclysm-dda Version: 0.E.2 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Turn-based survival game set in a post-apocalyptic world License: CC-BY-SA URL: http://cataclysmdda.org Source0: https://github.com/CleverRaven/Cataclysm-DDA/archive/0.E-2/%{name}-0.E-2.tar.gz +Patch0: cataclysm-dda-gcc11.patch # Due virtual memory exhausted and build fail ExcludeArch: i686 @@ -197,6 +198,10 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop %changelog +* Tue Sep 15 2020 Jeff Law - 0.E.2-6 +- Fix uninitialized variable caught by gcc-11. Fix dynamic casts + to avoid gcc-11 diagnostic + * Sat Aug 01 2020 Artem Polishchuk - 0.E.2-5 - Fix Fedora build flags invocation