[5802] compile problem

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Message
Author
User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

[5802] compile problem

#1 Post by Dilvish »

5802 breaks compilation for me (on Kubuntu Linux, at least up through SVN 5804, the last available version at time of post); I tried a clean svn installation and got the same problem. Reverting to version 5801 lets me compile fine. The compile error report is as follows; it looks like one of the ObjectMap functions might have been truncated.

Code: Select all

[  0%] [  0%] Building CXX object CMakeFiles/core_static.dir/Empire/Empire.cpp.o
Building CXX object CMakeFiles/core_static.dir/universe/Building.cpp.o
[ 20%] Built target parse_static
[ 21%] Building CXX object CMakeFiles/core_static.dir/universe/Condition.cpp.o
In file included from FreeOrion/universe/Universe.h:8:0,
                 from FreeOrion/universe/UniverseObject.h:5,
                 from FreeOrion/universe/Building.h:5,
                 from FreeOrion/universe/Building.cpp:1:
FreeOrion/universe/ObjectMap.h: In member function ‘const std::pair<int, const T*>* ObjectMap::const_iterator<T>::operator->() [with T = UniverseObject]’:
FreeOrion/universe/Building.cpp:227:27:   instantiated from here
FreeOrion/universe/ObjectMap.h:52:23: error: taking address of temporary [-fpermissive]
FreeOrion/Empire/Empire.cpp: In member function ‘const std::map<int, std::set<int> > Empire::VisibleStarlanes() const’:
FreeOrion/Empire/Empire.cpp:1802:22: warning: unused variable ‘objects’ [-Wunused-variable]
make[2]: *** [CMakeFiles/core_static.dir/universe/Building.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from FreeOrion/Empire/../universe/Universe.h:8:0,
                 from FreeOrion/Empire/../universe/UniverseObject.h:5,
                 from FreeOrion/Empire/Empire.h:8,
                 from FreeOrion/Empire/Empire.cpp:1:
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = System]’:
FreeOrion/Empire/Empire.cpp:1776:90:   instantiated from here
FreeOrion/Empire/../universe/ObjectMap.h:306:25: error: could not convert ‘(& ObjectMap::Map [with T = System]())->std::map<_Key, _Tp, _Compare, _Alloc>::begin [with _Key = int, _Tp = System*, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, System*> >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const int, System*> >]()’ from ‘std::map<int, System*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, System*> >}’ to ‘ObjectMap::value_iterator<System>’
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = System]’:
FreeOrion/Empire/Empire.cpp:1777:49:   instantiated from here
FreeOrion/Empire/../universe/ObjectMap.h:310:23: error: could not convert ‘(& ObjectMap::Map [with T = System]())->std::map<_Key, _Tp, _Compare, _Alloc>::end [with _Key = int, _Tp = System*, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, System*> >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const int, System*> >]()’ from ‘std::map<int, System*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, System*> >}’ to ‘ObjectMap::value_iterator<System>’
In file included from FreeOrion/Empire/../universe/Universe.h:8:0,
                 from FreeOrion/Empire/../universe/UniverseObject.h:5,
                 from FreeOrion/Empire/Empire.h:8,
                 from FreeOrion/Empire/Empire.cpp:1:
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘const std::pair<int, const T*>* ObjectMap::const_iterator<T>::operator->() [with T = System]’:
FreeOrion/Empire/../universe/ObjectMap.h:352:9:   instantiated from ‘std::vector<int> ObjectMap::FindObjectIDs() const [with T = System]’
FreeOrion/Empire/Empire.cpp:1460:101:   instantiated from here
FreeOrion/Empire/../universe/ObjectMap.h:52:23: error: taking address of temporary [-fpermissive]
In file included from FreeOrion/Empire/../universe/Universe.h:8:0,
                 from FreeOrion/Empire/../universe/UniverseObject.h:5,
                 from FreeOrion/Empire/Empire.h:8,
                 from FreeOrion/Empire/Empire.cpp:1:
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = Fleet]’:
FreeOrion/Empire/../universe/ObjectMap.h:343:49:   instantiated from ‘std::vector<T*> ObjectMap::FindObjects() [with T = Fleet]’
FreeOrion/Empire/Empire.cpp:1484:83:   instantiated from here
FreeOrion/Empire/../universe/ObjectMap.h:306:25: error: could not convert ‘(& ObjectMap::Map [with T = Fleet]())->std::map<_Key, _Tp, _Compare, _Alloc>::begin [with _Key = int, _Tp = Fleet*, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, Fleet*> >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const int, Fleet*> >]()’ from ‘std::map<int, Fleet*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, Fleet*> >}’ to ‘ObjectMap::value_iterator<Fleet>’
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = Fleet]’:
FreeOrion/Empire/../universe/ObjectMap.h:343:49:   instantiated from ‘std::vector<T*> ObjectMap::FindObjects() [with T = Fleet]’
FreeOrion/Empire/Empire.cpp:1484:83:   instantiated from here
FreeOrion/Empire/../universe/ObjectMap.h:310:23: error: could not convert ‘(& ObjectMap::Map [with T = Fleet]())->std::map<_Key, _Tp, _Compare, _Alloc>::end [with _Key = int, _Tp = Fleet*, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, Fleet*> >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const int, Fleet*> >]()’ from ‘std::map<int, Fleet*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, Fleet*> >}’ to ‘ObjectMap::value_iterator<Fleet>’
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = System]’:
FreeOrion/Empire/../universe/ObjectMap.h:306:28: warning: control reaches end of non-void function [-Wreturn-type]
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = System]’:
FreeOrion/Empire/../universe/ObjectMap.h:310:26: warning: control reaches end of non-void function [-Wreturn-type]
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = Fleet]’:
FreeOrion/Empire/../universe/ObjectMap.h:306:28: warning: control reaches end of non-void function [-Wreturn-type]
FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = Fleet]’:
FreeOrion/Empire/../universe/ObjectMap.h:310:26: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [CMakeFiles/core_static.dir/Empire/Empire.cpp.o] Error 1
In file included from FreeOrion/universe/Universe.h:8:0,
                 from FreeOrion/universe/UniverseObject.h:5,
                 from FreeOrion/universe/Condition.cpp:5:
FreeOrion/universe/ObjectMap.h: In member function ‘const std::pair<int, const T*>* ObjectMap::const_iterator<T>::operator->() [with T = UniverseObject]’:
FreeOrion/universe/Condition.cpp:170:55:   instantiated from here
FreeOrion/universe/ObjectMap.h:52:23: error: taking address of temporary [-fpermissive]
make[2]: *** [CMakeFiles/core_static.dir/universe/Condition.cpp.o] Error 1
make[1]: *** [CMakeFiles/core_static.dir/all] Error 2
make: *** [all] Error 2
*** Failed ***
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: [5802] compile problem

#2 Post by Vezzra »

Compilation on OSX is broken too. 5801 builds fine, but 5808 fails. I was able to fix two issues in the Moderator::DestroyUniverseObject::serialize template, but I still get a lot of error messages similar to this one:

Code: Select all

/Users/user/SoftwareProjekte/FO/current/Xcode/../universe/../Empire/../universe/ObjectMap.h:306:0 /Users/user/SoftwareProjekte/FO/current/Xcode/../universe/../Empire/../universe/ObjectMap.h:306: error: conversion from 'std::_Rb_tree_iterator<std::pair<const int, Fleet*> >' to non-scalar type 'ObjectMap::value_iterator<Fleet>' requested
Instead of "Fleet" there is also "System", "UniverseObject", etc.

Complete buildlog attached.
Attachments
BuildLog_2013-02-25_15-04-14.txt
(108.18 KiB) Downloaded 101 times

gvdm
Space Floater
Posts: 43
Joined: Sun Nov 06, 2011 11:04 am

Re: [5802] compile problem

#3 Post by gvdm »

Is this related? I was able to compile on ~5780 but now I can't.

Code: Select all

Scanning dependencies of target core_static
[  1%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/CombatFighter.cpp.o
[  2%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/CombatShip.cpp.o
[  2%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/Missile.cpp.o
[  2%] Building CXX object CMakeFiles/core_static.dir/combat/OpenSteer/PathingEngine.cpp.o
[  2%] Building CXX object CMakeFiles/core_static.dir/Empire/Empire.cpp.o
In file included from /home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/Universe.h:8:0,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/UniverseObject.h:5,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.h:8,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In instantiation of ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = System]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1776:90:   required from here
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:306:25: error: could not convert ‘(& ObjectMap::Map<System>())->std::map<_Key, _Tp, _Compare, _Alloc>::begin<int, System*, std::less<int>, std::allocator<std::pair<const int, System*> > >()’ from ‘std::map<int, System*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, System*> >}’ to ‘ObjectMap::value_iterator<System>’
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In instantiation of ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = System]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1777:49:   required from here
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:310:23: error: could not convert ‘(& ObjectMap::Map<System>())->std::map<_Key, _Tp, _Compare, _Alloc>::end<int, System*, std::less<int>, std::allocator<std::pair<const int, System*> > >()’ from ‘std::map<int, System*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, System*> >}’ to ‘ObjectMap::value_iterator<System>’
In file included from /home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/Universe.h:8:0,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/UniverseObject.h:5,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.h:8,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In instantiation of ‘const std::pair<int, const T*>* ObjectMap::const_iterator<T>::operator->() [with T = System]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:352:9:   required from ‘std::vector<int> ObjectMap::FindObjectIDs() const [with T = System]’
/home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1460:101:   required from here
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:52:23: error: taking address of temporary [-fpermissive]
In file included from /home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/Universe.h:8:0,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/UniverseObject.h:5,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.h:8,
                 from /home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In instantiation of ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = Fleet]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:343:49:   required from ‘std::vector<T*> ObjectMap::FindObjects() [with T = Fleet]’
/home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1484:83:   required from here
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:306:25: error: could not convert ‘(& ObjectMap::Map<Fleet>())->std::map<_Key, _Tp, _Compare, _Alloc>::begin<int, Fleet*, std::less<int>, std::allocator<std::pair<const int, Fleet*> > >()’ from ‘std::map<int, Fleet*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, Fleet*> >}’ to ‘ObjectMap::value_iterator<Fleet>’
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In instantiation of ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = Fleet]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:343:49:   required from ‘std::vector<T*> ObjectMap::FindObjects() [with T = Fleet]’
/home/gvdm/Games/freeorion/FreeOrion/Empire/Empire.cpp:1484:83:   required from here
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:310:23: error: could not convert ‘(& ObjectMap::Map<Fleet>())->std::map<_Key, _Tp, _Compare, _Alloc>::end<int, Fleet*, std::less<int>, std::allocator<std::pair<const int, Fleet*> > >()’ from ‘std::map<int, Fleet*>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, Fleet*> >}’ to ‘ObjectMap::value_iterator<Fleet>’
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = System]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:306:28: warning: control reaches end of non-void function [-Wreturn-type]
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = System]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:310:26: warning: control reaches end of non-void function [-Wreturn-type]
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::begin_values() [with T = Fleet]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:306:28: warning: control reaches end of non-void function [-Wreturn-type]
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h: In member function ‘ObjectMap::value_iterator<T> ObjectMap::end_values() [with T = Fleet]’:
/home/gvdm/Games/freeorion/FreeOrion/Empire/../universe/ObjectMap.h:310:26: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [CMakeFiles/core_static.dir/Empire/Empire.cpp.o] Error 1
make[1]: *** [CMakeFiles/core_static.dir/all] Error 2
make: *** [all] Error 2
I see that commits 5802 onwards touch this code.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: [5802] compile problem

#4 Post by Dilvish »

gvdm wrote:Is this related? I was able to compile on ~5780 but now I can't.
I see that commits 5802 onwards touch this code.
Yes, this is essentially the same errors I ran into. I'm hoping that BigJoe (who made the 5802 revisions) will be able to clear this up soon.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: [5802] compile problem

#5 Post by Bigjoe5 »

It looks like there are two problems:

1. In the ObjectMap::const_iterator (not value_iterator or const_value_iterator, though), the & operator is being used on the result of **this, which is returning a pair<int, T const *> not by reference. Looking at it now, I'm not totally sure why it works at all for me, though it definitely does.

2. In several places, I'm implicitly converting Map<T>().begin() or Map<T>().end() to ObjectMap::*iterator, relying on their constructors to do the conversion. Maybe VS is just lenient about this, but it sounds more like non-compliance on the part of your compilers...

I'll look into this when I get home, but for now if you want to try a possible fix, replace the body of ObjectMap::const_iterator::operator->

Code: Select all

        const std::pair<int, const T*>* operator ->() {
 
           return &**this;
 
       }
with the following:

Code: Select all

        const std::pair<int, const T*>* operator ->() {
 
           return std::map<int, T*>::const_iterator::operator->();
 
       }
and replace all the instances of implicit conversion from the result of the Map<T>() function to explicit calls to the constructor of the desired type, i.e.

Code: Select all

template <class T>
 
ObjectMap::const_value_iterator<T> ObjectMap::end_values() const
 
{ return Map<T>().end(); }
becomes

Code: Select all


template <class T>
 
ObjectMap::const_value_iterator<T> ObjectMap::end_values() const
 
{ return const_value_iterator<T>(Map<T>().end()); }
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: [5802] compile problem

#6 Post by Dilvish »

Bigjoe5 wrote:2. In several places, I'm implicitly converting Map<T>().begin() or Map<T>().end() to ObjectMap::*iterator, relying on their constructors to do the conversion. Maybe VS is just lenient about this, but it sounds more like non-compliance on the part of your compilers...
when you say "ObjectMap::*iterator" I assume you mean the "value_iterator", and the issue is not as simple as converting one type of iterator to another. What standard is it you're thinking our compilers are not compliant with?
and replace all the instances of implicit conversion from the result of the Map<T>() function to explicit calls to the constructor of the desired type, i.e.

Code: Select all

template <class T>
 
ObjectMap::const_value_iterator<T> ObjectMap::end_values() const
 
{ return Map<T>().end(); }
becomes

Code: Select all


template <class T>
 
ObjectMap::const_value_iterator<T> ObjectMap::end_values() const
 
{ return const_value_iterator<T>(Map<T>().end()); }
I had already tried that before messaging you, it gives the same error message as before, it can't convert the std::map<int, T*>::iterator to the ObjectMap::value_iterator<T>
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: [5802] compile problem

#7 Post by Dilvish »

Dilvish wrote: it can't convert the std::map<int, T*>::iterator to the ObjectMap::value_iterator<T>
A value_iterator constructor specifically devoted to this conversion would probably solve most of the errors we're seeing, but when I thought a little about how to accomplish it, it seemed I ran into problems with taking addresses of temporary objects (which also seems to arise elsewhere in relation to this), & so I punted.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: [5802] compile problem

#8 Post by Bigjoe5 »

Dilvish wrote: when you say "ObjectMap::*iterator" I assume you mean the "value_iterator", and the issue is not as simple as converting one type of iterator to another. What standard is it you're thinking our compilers are not compliant with?
I meant all 4 of the ObjectMap iterators, all of which have a constructor that takes an std::map<int, T*> as an argument. Any type with a single-parameter constructor (that's not marked with the keyword "explicit") should be implicitly convertible from the type of the parameter.
Dilvish wrote:
Dilvish wrote: it can't convert the std::map<int, T*>::iterator to the ObjectMap::value_iterator<T>
A value_iterator constructor specifically devoted to this conversion would probably solve most of the errors we're seeing...
One of us is misunderstanding the other. Such a constructor (or rather, my interpretation of what you mean by such a constructor) already exists, for all 4 iterators. How is what you're proposing different from that, and how is it different from what you tried/I recommended before?
Dilvish wrote:...I ran into problems with taking addresses of temporary objects (which also seems to arise elsewhere in relation to this)
Do you still get errors related to this when you apply my first suggestion above?
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: [5802] compile problem

#9 Post by Dilvish »

Bigjoe5 wrote:
Dilvish wrote: when you say "ObjectMap::*iterator" I assume you mean the "value_iterator", and the issue is not as simple as converting one type of iterator to another. What standard is it you're thinking our compilers are not compliant with?
I meant all 4 of the ObjectMap iterators, all of which have a constructor that takes an std::map<int, T*> as an argument. Any type with a single-parameter constructor (that's not marked with the keyword "explicit") should be implicitly convertible from the type of the parameter.
Dilvish wrote:
Dilvish wrote: it can't convert the std::map<int, T*>::iterator to the ObjectMap::value_iterator<T>
A value_iterator constructor specifically devoted to this conversion would probably solve most of the errors we're seeing...
One of us is misunderstanding the other. Such a constructor (or rather, my interpretation of what you mean by such a constructor) already exists, for all 4 iterators. How is what you're proposing different from that, and how is it different from what you tried/I recommended before?
Dilvish wrote:...I ran into problems with taking addresses of temporary objects (which also seems to arise elsewhere in relation to this)
Do you still get errors related to this when you apply my first suggestion above?
I dunno now, I was thinking the cost_iterator in the value_iterator constructor might be throwing it off, but I guess it's just conversions in the other direction that are trouble. Maybe I'm misremembering what errors I got when I tried it; I haven't tested the first suggestion yet. I'll test them both together when I get a chance, probably in a few hours.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: [5802] compile problem

#10 Post by Dilvish »

ok, so, a little bit of progress, perhaps:
BigJoe, your two suggestions still left my compiler complaining about the const_iterator's function const std::pair<int, const T*>* operator->() ; I tried a couple ways to get around it but wound up just kludging a circular reference to get past that compile error ( "return this->operator->()" ) (only to find a few more compile errors farther along, but I was able to get through those in reasonable ways). So, with the buried flaw it compiled fine , and starts up, but then during universe generation in PopulateSystems when it actually tries to use that operator it just hangs, as would be expected. I looked a bit more at how to fix it right, but didn't get it figured out yet.

I'm attaching a patch file that includes the changes other than the const_iterator const std::pair<int, const T*>* operator->() , since the later additional changes seem necessary for my system & I'm hopeful they're fine for windows. I'll step through the initial sequence of changes & errors so you see why I went the way I did; hopefully someone can see a way to fix the operator->() . There turned out to also be needed some small (unrelated) changes to ModeratorAction.h.

The initial suggestions left it with the error

Code: Select all

FreeOrion/Empire/../universe/ObjectMap.h:53:66: error::
cannot convert ‘std::_Rb_tree_const_iterator<std::pair<const int, System*> >::pointer {aka const std::pair<const int, System*>*}’ to ‘const std::pair<int, const System*>*’ in return
It took me a while looking at that until I saw the difference of 'const' before the 'int'. I tried just adding a corresponding 'const' into the return line and then got the error

Code: Select all

FreeOrion/Empire/../universe/ObjectMap.h:53:72: error:
cannot call member function ‘const _Tp* std::_Rb_tree_const_iterator<_Tp>::operator->() const [with _Tp = std::pair<const int, const System*>, std::_Rb_tree_const_iterator<_Tp>::pointer = const std::pair<const int, const System*>*]’ without object
I couldn't figure out how to fix it so I just changed the return line to

Code: Select all

return this-> operator->();
to get past the compilation error (but obviously it's not a true fix). I then got an unrelated error with some new serialization code that was easy to fix, and then back to difficulties with ObjectMap. I stopped keeping track of them at that point (well, I remember that one was that my compiler didn't want to work with some of the uses of "iterator<>", but they weren't too tricky to solve. But that's why there are more changes.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

[The extension patch has been deactivated and can no longer be displayed.]

[The extension patch has been deactivated and can no longer be displayed.]

If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: [5802] compile problem

#11 Post by Dilvish »

ya, I think I give up on this. I can get the original "return &**this;" to compile with just warnings if I add the -fpermissive compiler flag, but then the whole thing flat out crashes when it tries to do galaxy generation.

Does this stuff really not even generate warnings on Windows?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: [5802] compile problem

#12 Post by Vezzra »

Bigjoe5 wrote:Maybe VS is just lenient about this, but it sounds more like non-compliance on the part of your compilers...
I've tried to compile both with gcc and the llvm compiler. Both give me the same errors. I haven't found the time to try your suggested fixes though.
Dilvish wrote:Does this stuff really not even generate warnings on Windows?
What baffles me is the fact that this stuff obviously works on Windows.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: [5802] compile problem

#13 Post by Geoff the Medio »

Vezzra wrote:What baffles me is the fact that this stuff obviously works on Windows.
The Visual Studio compiler quite often will compile things that it shouldn't. Particularly with template code, I think it sometimes just ignores some code that it doesn't need, but which GCC decides to instantiate and generate compile errors from.

Edit: Try this?

I made several constructors take parameters by const reference, removed the implicit conversion of iterators to pointers, removed the returning of references to UniverseObject (pointers are sufficient and doing change the meaning of operator* on a container of pointers) rewrote various operator functions more explicitly, groomed the code to my preferences, and rewrote the problematic operator -> function for the const_iterator to use static casts through const void* to avoid the inability to const_cast directly between pair<const int, UniverseObject*>* and pair<const int, const UniverseObject*>* without dereferencing and assigning to a temporary variable and then taking its address (which might work occasionally, but is a probably a bad idea, and seems to have caused some GCC compile errors). Note that the casting to void* hack is similar to existing code in Effect.cpp.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]


User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: [5802] compile problem

#14 Post by Bigjoe5 »

Geoff the Medio wrote:Try this?
Sorry for being slow to react to this situation, but I'd prefer to clean up my own mess in this case. I'll provide a solution sometime tonight.
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: [5802] compile problem

#15 Post by Vezzra »

Geoff the Medio wrote:Try this?
Well, the errors seem to be different ones, although more. I just tried to compile ObjectMap.cpp, buildlog attached.
Attachments
BuildLog_2013-02-27_14-10-13.txt
(11.96 KiB) Downloaded 96 times

Post Reply