Azerothcore-wotlk: Using C++17 causes compile fail

Created on 11 Mar 2019  路  10Comments  路  Source: azerothcore/azerothcore-wotlk

SMALL DESCRIPTION:


e7ace60e59565833922c742a66cb2382be8f0ae6 causes compiling to fail with following error:

...
[ 19%] Built target authserver                                                                                                                                                                                                                
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundBE.cpp.o                                                                                                                                       
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/BattlegroundQueue.cpp.o                                                                                                                                          
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundAV.cpp.o                                                                                                                                       
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundDS.cpp.o                                                                                                                                       
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundEY.cpp.o                                                                                                                                       
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundIC.cpp.o                                                                                                                                       
[ 19%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundNA.cpp.o                                                                                                                                       
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/Battlegrounds/BattlegroundQueue.cpp:1:                                                                                                                         
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/PrecompiledHeaders/gamePCH.h:3:                                                                                                                                
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/Server/WorldSocket.h:29:                                                                                                                                       
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/common/Common.h:69:                                                                                                                                                        
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/set:60:                                                                                                                                   
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_tree.h:457:7: error: static_assert failed due to requirement 'is_invocable_v<const BgEmptinessComp &, Battleground *const &, Battleground *const &>'   
      "comparison object must be invocable as const"                                                                                                                                                                                          
      static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>,                                                                                                                                                                
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                 
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:133:17: note: in instantiation of template class 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>, BgEmptinessComp, 
      std::allocator<Battleground *> >' requested here                                                                                                                                                                                        
      _Rep_type _M_t;  // Red-black tree representing set.                                                                                                                                                                                    
                ^                                                                                                                                                                                                                             
/home/ayrton/Documents/azerothcore-wotlk/src/server/game/Battlegrounds/BattlegroundQueue.cpp:679:29: note: in instantiation of template class 'std::set<Battleground *, BgEmptinessComp, std::allocator<Battleground *> >' requested here     
        BattlegroundNeedSet bgsToCheck;                                                                                                                                                                                                       
                            ^                                                                                                                                                                                                                 
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/Battlegrounds/BattlegroundQueue.cpp:1:                                                                                                                         
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/PrecompiledHeaders/gamePCH.h:3:                                                                                                                                
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/Server/WorldSocket.h:29:                                                                                                                                       
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/common/Common.h:69:                                                                                                                                                        
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/set:61:                                                                                                                                   
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:147:35: error: no type named 'const_iterator' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>, BgEmptinessComp, 
      std::allocator<Battleground *> >'                                                                                                                                                                                                       
      typedef typename _Rep_type::const_iterator         iterator;                                                                                                                                                                            
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~                                                                                                                                                                                              
/home/ayrton/Documents/azerothcore-wotlk/src/server/game/Battlegrounds/BattlegroundQueue.cpp:679:29: note: in instantiation of template class 'std::set<Battleground *, BgEmptinessComp, std::allocator<Battleground *> >' requested here     
        BattlegroundNeedSet bgsToCheck;                                                                                                                                                                                                       
                            ^
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/Battlegrounds/BattlegroundQueue.cpp:1:                                                                                                                         
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/PrecompiledHeaders/gamePCH.h:3:                                                                                                                                
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/server/game/Server/WorldSocket.h:29:                                                                                                                                       
In file included from /home/ayrton/Documents/azerothcore-wotlk/src/common/Common.h:69:                                                                                                                                                        
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/set:61:                                                                                                                                  
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:148:35: error: no type named 'const_iterator' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>, BgEmptinessComp,
      std::allocator<Battleground *> >'                                                                                                                                                                                                      
      typedef typename _Rep_type::const_iterator         const_iterator;                                                                                                                                                                     
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~                                                                                                                                                                                             
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:149:35: error: no type named 'const_reverse_iterator' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>,         
      BgEmptinessComp, std::allocator<Battleground *> >'                                                                                                                                                                                     
      typedef typename _Rep_type::const_reverse_iterator reverse_iterator;                                                                                                                                                                   
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                     
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:150:35: error: no type named 'const_reverse_iterator' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>,         
      BgEmptinessComp, std::allocator<Battleground *> >'                                                                                                                                                                                     
      typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;                                                                                                                                                             
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                     
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:151:35: error: no type named 'size_type' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>, BgEmptinessComp,     
      std::allocator<Battleground *> >'
      typedef typename _Rep_type::size_type              size_type;                                                                                                                                                                          
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~                                                                                                                                                                                                  
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:152:35: error: no type named 'difference_type' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>, BgEmptinessComp,
      std::allocator<Battleground *> >'
      typedef typename _Rep_type::difference_type        difference_type;                                                                                                                                                                    
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~                                                                                                                                                                                            
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:156:45: error: no type named 'node_type' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>, BgEmptinessComp,     
      std::allocator<Battleground *> >'
      using node_type = typename _Rep_type::node_type;                                                                                                                                                                                       
                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~                                                                                                                                                                                        
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_set.h:157:54: error: no type named 'insert_return_type' in 'std::_Rb_tree<Battleground *, Battleground *, std::_Identity<Battleground *>,             
      BgEmptinessComp, std::allocator<Battleground *> >'
      using insert_return_type = typename _Rep_type::insert_return_type;
                                 ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/home/ayrton/Documents/azerothcore-wotlk/src/server/game/Battlegrounds/BattlegroundQueue.cpp:693:32: error: indirection requires pointer operand ('BattlegroundNeedSet::iterator' (aka 'int') invalid)
            Battleground* bg = *itr;
                               ^~~~
[ 78%] Built target scripts
[ 78%] Building CXX object src/server/game/CMakeFiles/game.dir/Battlegrounds/Zones/BattlegroundRL.cpp.o
10 errors generated.
make[2]: *** [src/server/game/CMakeFiles/game.dir/build.make:453: src/server/game/CMakeFiles/game.dir/Battlegrounds/BattlegroundQueue.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:905: src/server/game/CMakeFiles/game.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Reverting e7ace60e59565833922c742a66cb2382be8f0ae6 fixes the issue.

EXPECTED BLIZZLIKE BEHAVIOUR:
CURRENT BEHAVIOUR:
STEPS TO REPRODUCE THE PROBLEM:

  1. Clone repo.
  2. mkdir build && cmake cmake ../ -DCMAKE_INSTALL_PREFIX=/tmp -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DTOOLS=0 -DSCRIPTS=1 -DMARIADB=1
  3. make
EXTRA NOTES:
BRANCH(ES):

master

AC HASH/COMMIT:


1d0a8dbba0b7f17b433e8e1efbc2bd08282bd28a

OPERATING SYSTEM:


Linux 5.0.0-arch1-1-ARCH #1 SMP PREEMPT Mon Mar 4 14:11:43 UTC 2019 x86_64 GNU/Linux

MODULES:


None

OTHER CUSTOMIZATIONS:


None

All 10 comments

what clang version you have?

$ clang --version
clang version 7.0.1 (tags/RELEASE_701/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

"Comparison operators should've always been const. This unspoken rule is now being actively enforced. " (stackoverflow)

This new version of clang enforce the const property during the comparison by operators.

For the first error

In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/set:60:                                                                                                                                   
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/stl_tree.h:457:7: error: static_assert failed due to requirement 'is_invocable_v<const BgEmptinessComp &, Battleground *const &, Battleground *const &>'   
      "comparison object must be invocable as const"                                                                                                                                                                                          
      static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>, 

I think that the problem is the library , that isn't updated at the new clang version.

@FallingSnow can you try replacing:

-std=c++1z

with:

-std=c++17

and see if the problem is solved then ?

No, same result.

Deleted directory and recloned.

...
-- Using mysql-config: /usr/bin/mysql_config
-- Found MySQL library: /usr/lib/libmariadb.so
-- Found MySQL headers: /usr/include/mysql
-- Found Readline library: /usr/lib/libreadline.so
-- Include dir is: /usr/include
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11")
-- Found BZip2: /usr/lib/libbz2.so (found version "1.0.6")
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Found git binary : /usr/bin/git
RegularExpression::compile(): Nested *?+.
RegularExpression::compile(): Error in compile.
CMake Error at src/cmake/genrev.cmake:75 (if):
  if given arguments:

    "NOT" "" "MATCHES" "3a75fd8710e1" "OR" "NOT" "" "MATCHES" "c++14" "OR" "NOT" "EXISTS" "[redacted]/azerothcore-wotlk/build/revision.h"                                                                                         

  Regular expression "c++14" cannot compile
Call Stack (most recent call first):
  CMakeLists.txt:112 (include)


-- Configuring incomplete, errors occurred!
See also "[redacted]/azerothcore-wotlk/build/CMakeFiles/CMakeOutput.log".
See also "[redacted]/azerothcore-wotlk/build/CMakeFiles/CMakeError.log".

Let me know if you need more of the logs.

@FallingSnow what about -std=c++1y ?

The issue seems to be with Cmake viewing c++14 as regex and since c++14 is in fact invalid regex this is a valid error. Since we should be matching strings and not regex we should alter the genrev.cmake code.

This patch fixes the issue.

From 5907ae7cdd4eeae7360755bd9acd94dcc9fff902 Mon Sep 17 00:00:00 2001
From: FallingSnow <[email protected]>
Date: Wed, 20 Mar 2019 22:10:01 +0000
Subject: [PATCH] Swap cmake REGEX for STREQUAL

---
 src/cmake/genrev.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cmake/genrev.cmake b/src/cmake/genrev.cmake
index 5c3e61d..e1deb0d 100644
--- a/src/cmake/genrev.cmake
+++ b/src/cmake/genrev.cmake
@@ -72,7 +72,7 @@ else()
 endif()

 # Create the actual revision.h file from the above params
-if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}" OR NOT EXISTS "${BUILDDIR}/revision.h")
+if(NOT "${rev_hash_cached}" STREQUAL "${rev_hash}" OR NOT "${rev_branch_cached}" STREQUAL "${rev_branch}" OR NOT EXISTS "${BUILDDIR}/revision.h")
   configure_file(
     "${CMAKE_SOURCE_DIR}/src/cmake/revision.h.in.cmake"
     "${BUILDDIR}/revision.h"
-- 
2.20.1

After this patch branch c++14 now compiles.

@FallingSnow thanks, I've updated the PR. Can you please try it again? Please leave the feedback under the PR discussion:

https://github.com/azerothcore/azerothcore-wotlk/pull/1595

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Franklampardst picture Franklampardst  路  4Comments

lineagedr picture lineagedr  路  3Comments

FrancescoBorzi picture FrancescoBorzi  路  3Comments

wowissues picture wowissues  路  3Comments

Franklampardst picture Franklampardst  路  3Comments