Skip to content

Commit

Permalink
Fix error with size-0 array; add -pedantic to compiler options.
Browse files Browse the repository at this point in the history
-pedantic gives stricter standard compliance on gcc/clang, and would
have catched this error where only VS complained.
  • Loading branch information
scamille committed Mar 27, 2018
1 parent a8167b3 commit fb16e18
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion engine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ endif

MKDIR = mkdir
CXX = g++
CPP_FLAGS = -Wall -Wextra -Woverloaded-virtual -W -I. -DSC_SHARED_DATA=\"$(SHARED_DATA)\" --std=c++11 -O3 -MMD -MP
CPP_FLAGS = -Wall -Wextra -Woverloaded-virtual -W -I. -DSC_SHARED_DATA=\"$(SHARED_DATA)\" --std=c++11 -O3 -MMD -MP -pedantic
OPTS =
GIT = $(shell [ -d ../.git ] && which git)

Expand Down
6 changes: 3 additions & 3 deletions engine/class_modules/warlock/sc_warlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,19 @@ namespace warlock
{
action_list_str = "shadow_bite";
owner_coeff.ap_from_sp *= 1.2;
};
}

void felhunter_pet_t::init_base_stats()
{
warlock_pet_t::init_base_stats();
melee_attack = new warlock_pet_melee_t( this );
};
}

action_t* felhunter_pet_t::create_action( const std::string& name, const std::string& options_str )
{
if ( name == "shadow_bite" ) return new shadow_bite_t( this );
return warlock_pet_t::create_action( name, options_str );
};
}
}

namespace imp
Expand Down
8 changes: 7 additions & 1 deletion engine/player/sc_enchant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace /* ANONYMOUS NAMESPACE */
* applicable. The enchant ID (number) maps to the array of
* item_enchantment_data_t structs in sc_item_data.inc.
*/
const enchant_db_item_t __enchant_db[] = {};
const enchant_db_item_t __enchant_db[] = {
{ nullptr, 0 } // Dummy entry since we can not have a array with size 0.
};

size_t enchant_map_key(const dbc_t& dbc, const item_enchantment_data_t& enchant)
{
Expand All @@ -33,6 +35,8 @@ unsigned enchant::find_enchant_id( const std::string& name )
{
for ( auto& enchant_entry : __enchant_db )
{
if ( !enchant_entry.enchant_name )
continue;
if ( util::str_compare_ci( enchant_entry.enchant_name, name ) )
return enchant_entry.enchant_id;
}
Expand All @@ -44,6 +48,8 @@ std::string enchant::find_enchant_name( unsigned enchant_id )
{
for ( auto& enchant_entry : __enchant_db )
{
if ( !enchant_entry.enchant_name )
continue;
if ( enchant_entry.enchant_id == enchant_id )
return enchant_entry.enchant_name;
}
Expand Down
2 changes: 1 addition & 1 deletion engine/player/sc_unique_gear_x7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,7 @@ void item::riftworld_codex( special_effect_t& effect )
};

new riftworld_codex_callback_t( effect, buffs );
};
}

// Toe Knee's Promise ======================================================

Expand Down

0 comments on commit fb16e18

Please sign in to comment.