Skip to content

Commit 8deb20f

Browse files
committed
Explicitly initialize stuff in ScenarioActivityConfigGUI
Undefined sanitizer's complaint: ../Source/Menus/ScenarioActivityConfigGUI.cpp:101:59: runtime error: load of value 190, which is not a valid value for type 'bool' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../Source/Menus/ScenarioActivityConfigGUI.cpp:101:59 ...While working on this one, I discovered that C++ "default-initializes" class members, which leaves primitives and pointers with undefined garbage values, but properly initializes classes. And also the [Most vexing parse](https://en.wikipedia.org/wiki/Most_vexing_parse). Wow.
1 parent 0caf5c5 commit 8deb20f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Source/Menus/ScenarioActivityConfigGUI.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ ScenarioActivityConfigGUI::ScenarioActivityConfigGUI(GUIControlManager* parentCo
6565
m_CPULockLabel = dynamic_cast<GUILabel*>(m_GUIControlManager->GetControl("LabelCPUTeamLock"));
6666
m_StartErrorLabel = dynamic_cast<GUILabel*>(m_GUIControlManager->GetControl("LabelStartError"));
6767
m_StartGameButton = dynamic_cast<GUIButton*>(m_GUIControlManager->GetControl("ButtonStartGame"));
68-
69-
m_TechListFetched = false;
7068
}
7169

7270
void ScenarioActivityConfigGUI::PopulateTechComboBoxes() {

Source/Menus/ScenarioActivityConfigGUI.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ namespace RTE {
6565

6666
GUIControlManager* m_GUIControlManager; //!< The GUIControlManager which holds all the GUIControls of this menu. Not owned by this.
6767

68-
const GameActivity* m_SelectedActivity; //!< The Activity this ScenarioActivityConfigGUI is configuring.
69-
const GameActivity* m_PreviouslySelectedActivity; //!< The Activity this ScenarioActivityConfigGUI was configuring last, before it got was disabled.
70-
Scene* m_SelectedScene; //!< The Scene the selected Activity will be using.
68+
const GameActivity* m_SelectedActivity = nullptr; //!< The Activity this ScenarioActivityConfigGUI is configuring.
69+
const GameActivity* m_PreviouslySelectedActivity = nullptr; //!< The Activity this ScenarioActivityConfigGUI was configuring last, before it got was disabled.
70+
Scene* m_SelectedScene = nullptr; //!< The Scene the selected Activity will be using.
7171
int m_LockedCPUTeam = Activity::Teams::NoTeam; //!< Which team the CPU is locked to, if any.
7272

73-
bool m_StartingGoldAdjustedManually {}; //!< Whether the player adjusted the starting gold, meaning it should stop automatically adjusting to the difficulty setting default starting gold where applicable.
73+
bool m_StartingGoldAdjustedManually = false; //!< Whether the player adjusted the starting gold, meaning it should stop automatically adjusting to the difficulty setting default starting gold where applicable.
7474

7575
Timer m_StartGameButtonBlinkTimer; //!< Timer for blinking the start game button.
7676

77-
bool m_TechListFetched; //!< Whether the tech list was fetched and each team's ComboBox was populated with it, even if no valid tech modules were added.
77+
bool m_TechListFetched = false; //!< Whether the tech list was fetched and each team's ComboBox was populated with it, even if no valid tech modules were added.
7878

7979
/// GUI elements that compose the Activity setup box.
8080
GUICollectionBox* m_ActivityConfigBox;

0 commit comments

Comments
 (0)