rcsoccersim / rcssserver

The RoboCup Soccer Simulator Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warnings and errors when compiling on Arch Linux

FelipeCoimbra opened this issue · comments

There are warnings of deprecated use of auto_ptr from the beginning of the compilation.

In file included from rule.cpp:26:0:
rule.h:91:10: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     std::auto_ptr< Rule > deepCopy() const = 0;
          ^~~~~~~~
In file included from /usr/include/c++/7.3.0/memory:80:0,
                 from rule.h:28,
                 from rule.cpp:26:
/usr/include/c++/7.3.0/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~

The first compilation error reported appears as

rule.cpp: In member function ‘virtual std::ostream& rcss::clang::SimpleRule::printPretty(std::ostream&, const string&) const’:
rule.cpp:289:13: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘std::ostream {aka std::basic_ostream<char>}’)
         out << (*i)->printPretty( out, lineheader + " -" );
         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The complete error may be read here https://pastebin.com/Tsw4RtPL

And there's one more error right after, that seems much more of the same

rule.cpp: In member function ‘virtual std::ostream& rcss::clang::NestedRule::printPretty(std::ostream&, const string&) const’:
rule.cpp:383:13: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘std::ostream {aka std::basic_ostream<char>}’)
         out << (*i)->printPretty( out, lineheader + " -" );
         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To get the server running I had to comment these lines out. Any ideas to fix this? My Arch is up-to-date with 4.17.3-1-ARCH kernel

Thanks for reporting the issue.
Unfortunately, I don't have the environment of Arch Linux, but try to fix it.

I don't think this is an Arch Linux error. I have the same errors in Ubuntu. It has to do with the fact that auto_ptr was deprecated in C++11 and removed in C++17. There is wide use of auto_ptr the in rule,region,clangmsgbuilder, and coach_lang_comp files. These need to be replaced with some combination of unique_ptr and shared_ptr. Are there any efforts underway to do so?

I also have recognized the problem of auto_ptr (this is not my implementation...) and am trying to fix them. But, unfortunately, we don't have enough human resources because the current maintainer is only me. Patches or pull requests are welcome.

@marcinic with which Ubuntu version did you get this error? I also would appreciate the gcc/g++ versions used in compilation

gcc --version
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
I am using Ubuntu 18.04 bionic.
@hidehisaakiyama I'm looking into it with the strategy of converting them to unique_ptr and then fixing the resulting compiler errors. It is my understanding that anything that uses deepCopy and should be a shared_ptr. I will keep you posted.

The following patch worked for me:

--- ../../Downloads/rcssserver-15.4.0/src/rule.cpp	2017-05-07 03:10:15.000000000 -0300
+++ rule.cpp	2018-07-24 05:38:57.087773226 -0300
@@ -286,7 +286,7 @@
           i != getDirs().end();
           ++i )
     {
-        out << (*i)->printPretty( out, lineheader + " -" );
+        out << (*i)->printPretty( out, lineheader + " -" ).rdbuf();
     }
     return out;
 }
@@ -380,7 +380,7 @@
           i != getRules().end();
           ++i )
     {
-        out << (*i)->printPretty( out, lineheader + " -" );
+        out << (*i)->printPretty( out, lineheader + " -" ).rdbuf();
     }
     return out;
 }
@@ -432,7 +432,7 @@
                          const std::string & lineheader ) const
 {
     out << lineheader << "IDList Rule:\n";
-    return out << M_rids.printPretty( out, lineheader + " -" );
+    return out << M_rids.printPretty( out, lineheader + " -" ).rdbuf();
 }
 
 std::auto_ptr< Rule >

Although the auto_ptr issue has to be fixed, the problem is there is no << operator for std::ostream << std::ostream, the << operator works only for string likes objects.

I create a patch for the auto_ptr issue too, maybe help, it works in my computer.
https://gist.github.com/vasconssa/b3d2813aa37b5b8bd06ade26c1c8602d

@vasconssa Great job. This works for me as well. Do you want to make a pull request?

@marcinic did you test the patch with the auto_ptr fix or just the printPretty one? To try fix the auto_ptr i just changed auto_ptr to unique_ptr and then fixed the compilation errors, I practically had to insert std: move where the errors occurred.

I just merged my working branch. I hope problems related to auto_ptr have been solved in the latest master.

It works now using v15.5.0.

This issue can be closed