Login
User Name:

Password:



Register

Forgot your password?
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
SWRFUSS 1.4
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.4
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.3
Author: Various
Submitted by: Samson
Users Online
CommonCrawl, AhrefsBot, SemrushBot, Bing

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
486
3,758
19,453
572
Fjolsvith

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Codebases » AFKMud Support & Development » Strange skill sort error in G...
Forum Rules | Mark all | Recent Posts

Strange skill sort error in GGC 8 compile
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 17, 2020 1:40 am   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,665
JoinedJan 1, 2002

 
I'm preparing an update for AFKMud that will clean up the compile for GCC 8 and ran into something really strange that I don't understand with the skills.cpp file. Here's the error:
Building AFKMud....
make -j2 -s afkmud
  Compiling o/skills.o....
In file included from /usr/include/c++/8/map:60,
                 from mud.h:37,
                 from skills.cpp:33:
/usr/include/c++/8/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = std::__cxx11::basic_string; _Val = std::pair, int>; _KeyOfValue = std::_Select1st, int> >; _Compare = string_sort; _Alloc = std::allocator, int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node, int> >*]’:
/usr/include/c++/8/bits/stl_tree.h:2425:62:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple, std::allocator >&>, std::tuple<>}; _Key = std::__cxx11::basic_string; _Val = std::pair, int>; _KeyOfValue = std::_Select1st, int> >; _Compare = string_sort; _Alloc = std::allocator, int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator, int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator, int> >]’
/usr/include/c++/8/bits/stl_map.h:499:8:   required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string; _Tp = int; _Compare = string_sort; _Alloc = std::allocator, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::__cxx11::basic_string]’
skills.cpp:728:26:   required from here
/usr/include/c++/8/bits/stl_tree.h:777:8: error: static assertion failed: comparison object must be invocable as const
        is_invocable_v,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Makefile:191: recipe for target 'o/skills.o' failed
make[1]: *** [o/skills.o] Error 1
Makefile:128: recipe for target 'all' failed
make: *** [all] Error 2


Yeah, a big fat mess, right? The Makefile currently includes the -std=c++1z directive, which it turns out is responsible for this. Backing off to -std=c++17 returns the same error, but -std=c++14 doesn't and the entire codebase will compile.

What I don't get is why this is happening, and why only on the one line. Here's the function:
void update_skill_index( skill_type * skill, int sn )
{
   string buf = strlower( skill->name );

   skill_table__index[buf] = sn; <---- This is line 728, the one throwing that huge error.

   switch ( skill->type )
   {
      default:
         bug( "%s: Invalid skill type %d", __func__, skill->type );
         break;

      case SKILL_SPELL:
         skill_table__spell[buf] = sn;
         break;

      case SKILL_SKILL:
         skill_table__skill[buf] = sn;
         break;

      case SKILL_RACIAL:
         skill_table__racial[buf] = sn;
         break;

      case SKILL_COMBAT:
         skill_table__combat[buf] = sn;
         break;

      case SKILL_TONGUE:
         skill_table__tongue[buf] = sn;
         break;

      case SKILL_LORE:
         skill_table__lore[buf] = sn;
         break;
   }
}


Here's the entire skill_index.h file for reference:
// This probably isn't necessary, but prefer to sort by the contents of the
// string rather than the binary value that std::less uses.
class string_sort
{
 public:
   string_sort(  );
   bool operator(  ) ( const string &, const string & );
};

#if defined(__APPLE__)
//Just deciding to go with default std:less for MacOSX
typedef map < string, int > SKILL_INDEX;
#else
typedef map < string, int, string_sort > SKILL_INDEX;
#endif

extern SKILL_INDEX skill_table__index;
extern SKILL_INDEX skill_table__spell;
extern SKILL_INDEX skill_table__skill;
extern SKILL_INDEX skill_table__racial;
extern SKILL_INDEX skill_table__combat;
extern SKILL_INDEX skill_table__tongue;
extern SKILL_INDEX skill_table__lore;

class find__skill_prefix
{
 public:
   string value;
   char_data *actor;

     find__skill_prefix( char_data *, const string & );
   bool operator(  ) ( pair < string, int >compare );
};

class find__skill_exact
{
 public:
   string value;
   char_data *actor;

     find__skill_exact( char_data *, const string & );
   bool operator(  ) ( pair < string, int >compare );
};


What I don't get is that it complains only about skill_table__index but none of the rest of the index tables in the function.

Note that I didn't write this indexing code so I have no idea what the error is even trying to tell me.

Post is unread #2 Mar 17, 2020 2:25 am   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,665
JoinedJan 1, 2002

 
Ok, so, I don't know why this was necessary (cryptic errors suck) but the fix to get it compiling again was simple:

skill_index.h
class string_sort
{
 public:
   string_sort(  );
   bool operator(  ) ( const string &, const string & ) const;
};


skills.cpp
bool string_sort::operator(  ) ( const string & left, const string & right ) const
{
   return ( left.compare( right ) < 0 );
}


Sometimes going down the rabbit hole on Google leads to a good guess at a fix :P

Pages:<< prev 1 next >>