View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0003764 | Spring engine | Linux | public | 2013-04-30 16:09 | 2013-05-01 13:34 | ||||
Reporter | cleanrock | ||||||||
Assigned To | cleanrock | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | 94.1.1+git | ||||||||
Target Version | Fixed in Version | 95.0 | |||||||
Summary | 0003764: build error with C++11 | ||||||||
Description | I see this odd build error when i build with C++11 (cmake default now): $ make spring [ 47%] Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Game/GameServer.cpp.o cd /home/johanr/my_projects/spring/build_develop/rts/builds/legacy && /usr/bin/c++ -DBOOST_NO_FENV_H -DSPRING_DATADIR=\"/home/johanr/spring_develop/share/games/spring\" -DSTREFLOP_SSE -DSYNCCHECK -DUSE_LIBSQUISH -DUSE_VALGRIND -D_GLIBCXX_USE_NANOSLEEP -D_RANDOM_TCC -fopenmp -std=gnu++11 -mtune=generic -msse -mfpmath=sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a -mno-avx -mno-fma -mno-fma4 -mno-xop -mno-lwp -mno-avx2 -fsingle-precision-constant -frounding-math -mieee-fp -pipe -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pthread -O2 -DNDEBUG -g -I/home/johanr/my_projects/spring/rts/lib/lua/include -I/home/johanr/my_projects/spring/include/AL -I/home/johanr/my_projects/spring/rts/lib -I/home/johanr/my_projects/spring/rts -I/home/johanr/my_projects/spring/build_develop/src-generated/engine -I/usr/include/SDL -I/usr/include/freetype2 -I/usr/include/AL -o CMakeFiles/engine-legacy.dir/__/__/Game/GameServer.cpp.o -c /home/johanr/my_projects/spring/rts/Game/GameServer.cpp /home/johanr/my_projects/spring/rts/Game/GameServer.cpp: In member function ‘void CGameServer::ServerReadNet()’: /home/johanr/my_projects/spring/rts/Game/GameServer.cpp:1801:17: error: cannot convert ‘boost::shared_ptr<const netcode::RawPacket>’ to ‘bool’ in assignment dropPacket = (packet = link->Peek(globalConfig->linkIncomingMaxWaitingPackets)); ^ make[3]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Game/GameServer.cpp.o] Error 1 boost::shared_ptr shall have a operator bool so its a bit odd. If i disable C++11 in cmake spring builds fine. | ||||||||
Additional Information | develop f27a86 $ gcc --version gcc (GCC) 4.8.0 20130411 (prerelease) boost 1.53.0 | ||||||||
Tags | No tags attached. | ||||||||
Checked infolog.txt for Errors | |||||||||
Attached Files |
|
![]() |
|
abma (administrator) 2013-04-30 18:27 |
code is: dropPacket bool; boost::shared_ptr<const RawPacket> packet; boost::shared_ptr<netcode::CConnection> &link [...] dropPacket = (packet = link->Peek(globalConfig->linkIncomingMaxWaitingPackets)); i wouldn't say odd... error message is clear, but i don't know what the code shall do. (packet == link->Peek ... ? |
abma (administrator) 2013-04-30 18:29 |
note: imo the code is odd, not the error message :) |
jK (developer) 2013-04-30 20:57 |
shared_ptr has "explicit operator bool() const;" |
jK (developer) 2013-04-30 21:03 |
likely the "explicit" causes the problem can you test if it works if you split the assignments?: packet = link->Peek(globalConfig->linkIncomingMaxWaitingPackets); dropPacket = packet; |
cleanrock (reporter) 2013-05-01 00:13 |
Split is not enough. Seems assigning to a bool variable is not explicit enough, see: http://boost.2283326.n4.nabble.com/smart-ptr-thread-test-breaking-change-on-shared-ptr-operator-bool-td4639664.html I suggest this change which makes it compile for me: diff --git a/rts/Game/GameServer.cpp b/rts/Game/GameServer.cpp index 4fd0077..438df02 100644 --- a/rts/Game/GameServer.cpp +++ b/rts/Game/GameServer.cpp @@ -1798,7 +1798,7 @@ void CGameServer::ServerReadNet() bool bwLimitIsReached = globalConfig->linkIncomingPeakBandwidth > 0 && bandwidthUsage > globalConfig->linkIncomingPeakBandwidth; while (link) { if (dropPacket) - dropPacket = (packet = link->Peek(globalConfig->linkIncomingMaxWaitingPackets)); + dropPacket = (packet = link->Peek(globalConfig->linkIncomingMaxWaitingPackets)) != 0; packet = (!bwLimitIsReached || dropPacket) ? link->GetData() : link->Peek(ahead++); if (!packet) break; PS. I know you prefer NULL over 0, i think we should use 0 :) |
cleanrock (reporter) 2013-05-01 00:14 Last edited: 2013-05-01 00:27 |
Pasting diffs here is not that great obviously. |
jK (developer) 2013-05-01 00:49 |
use "!!(packet = link->Peek(globalConfig->linkIncomingMaxWaitingPackets))" then |
abma (administrator) 2013-05-01 13:34 |
https://github.com/spring/spring/commit/bdc775a2c9891b6d17548d6743fe6ec550d2830e |
![]() |
|||
Date Modified | Username | Field | Change |
---|---|---|---|
2013-04-30 16:09 | cleanrock | New Issue | |
2013-04-30 18:27 | abma | Note Added: 0010592 | |
2013-04-30 18:29 | abma | Note Added: 0010593 | |
2013-04-30 20:57 | jK | Note Added: 0010594 | |
2013-04-30 21:03 | jK | Note Added: 0010595 | |
2013-05-01 00:13 | cleanrock | Note Added: 0010596 | |
2013-05-01 00:14 | cleanrock | Note Added: 0010597 | |
2013-05-01 00:27 | cleanrock | Note Edited: 0010597 | View Revisions |
2013-05-01 00:49 | jK | Note Added: 0010598 | |
2013-05-01 13:34 | abma | Note Added: 0010601 | |
2013-05-01 13:34 | abma | Status | new => resolved |
2013-05-01 13:34 | abma | Fixed in Version | => 95.0 |
2013-05-01 13:34 | abma | Resolution | open => fixed |
2013-05-01 13:34 | abma | Assigned To | => cleanrock |