Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 582576 - games-emulation/sdlmame-0.173 fails to compile compile with gcc-4.9.3: strformat.h: error: 'cbegin' is not a member of 'std'
Summary: games-emulation/sdlmame-0.173 fails to compile compile with gcc-4.9.3: strfor...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Games (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Games
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-09 13:33 UTC by Alexander Miller
Modified: 2016-06-30 16:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
cxx14-compat.patch (cxx14-compat.patch,665 bytes, patch)
2016-05-09 13:33 UTC, Alexander Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Miller 2016-05-09 13:33:30 UTC
Created attachment 433772 [details, diff]
cxx14-compat.patch

Here's the relevant part of the build log:

-- >8 --
Precompiling src/emu/emu.h...
x86_64-pc-linux-gnu-g++ ${CXXFLAGS} ${CXXFLAGS}  -MMD -MP -MP -DPTR64=1 -DNDEBUG -DCRLF=2 -DLSB_FIRST -DXMD_H -DFLAC__NO_DLL -DNATIVE_DRC=drcbe_x64 -DLUA_COMPAT_ALL -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DUSE_OPENMP=1 -I../../../../../src/osd -I../../../../../src/emu -I../../../../../src/lib/util  -m64 --pipe -Wno-deprecated-declarations -O3 -fno-strict-aliasing -fopenmp -Wall -Wcast-align -Wundef -Wformat-security -Wwrite-strings -Wno-sign-compare -Wno-conversion -Wno-unused-result -Wno-array-bounds -m64 -x c++ -std=c++14 -Woverloaded-virtual -x c++-header -DPTR64=1 -DNDEBUG -DCRLF=2 -DLSB_FIRST -DXMD_H -DFLAC__NO_DLL -DNATIVE_DRC=drcbe_x64 -DLUA_COMPAT_ALL -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DUSE_OPENMP=1 -I../../../../../src/osd -I../../../../../src/emu -I../../../../../src/lib/util -o "../../../../linux_gcc/obj/x64/Release/emu.h.gch" -c "../../../../../src/emu/emu.h"
In file included from ../../../../../src/lib/util/corestr.h:17:0,
                 from ../../../../../src/emu/emucore.h:36,
                 from ../../../../../src/emu/emu.h:28:
../../../../../src/lib/util/strformat.h: In constructor 'util::detail::format_argument_pack<Stream>::format_argument_pack(Format&&, const util::detail::format_argument<Stream>*, std::enable_if_t<util::detail::format_argument_pack<Stream>::handle_char_array<typename std::remove_reference<Format>::type>::value, long unsigned int>)':
../../../../../src/lib/util/strformat.h:1097:13: error: 'cbegin' is not a member of 'std'
   : m_begin(std::cbegin(fmt))
             ^
../../../../../src/lib/util/strformat.h:1098:11: error: 'cend' is not a member of 'std'
   , m_end(std::cend(fmt))
           ^
../../../../../src/lib/util/strformat.h: In constructor 'util::detail::format_argument_pack<Stream>::format_argument_pack(Format&&, const util::detail::format_argument<Stream>*, std::enable_if_t<util::detail::format_argument_pack<Stream>::handle_container<typename std::remove_reference<Format>::type>::value, long unsigned int>)':
../../../../../src/lib/util/strformat.h:1113:39: error: 'cbegin' is not a member of 'std'
   : m_begin(fmt.empty() ? nullptr : &*std::cbegin(fmt))
                                       ^
../../../../../src/lib/util/strformat.h:1114:60: error: 'cbegin' is not a member of 'std'
   , m_end(fmt.empty() ? nullptr : (m_begin + std::distance(std::cbegin(fmt), st
                                                            ^
../../../../../src/lib/util/strformat.h:1114:78: error: 'cend' is not a member of 'std'
 (fmt.empty() ? nullptr : (m_begin + std::distance(std::cbegin(fmt), std::cend(f
                                                                     ^
precompile.make:263: recipe for target '../../../../linux_gcc/obj/x64/Release/emu.h.gch' failed
make[2]: *** [../../../../linux_gcc/obj/x64/Release/emu.h.gch] Error 1
Makefile:58: recipe for target 'precompile' failed
make[1]: *** [precompile] Error 2
make[1]: Leaving directory '/tmp/portage/games-emulation/sdlmame-0.173/work/build/projects/sdl/mame/gmake-linux'
makefile:1192: recipe for target 'linux_x64' failed
make: *** [linux_x64] Error 2
 * ERROR: games-emulation/sdlmame-0.173::gentoo failed (compile phase):
 *   emake failed
-->8 --

The problem is that gcc-4.9's support for C++14 is experimental and incomplete. The global functions cbegin, cend, etc. were added in gcc-5.1 (see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64656>).
There is a workaround in mame's strformat.h, but the check whether to enable it is broken. That check was changed here: <https://github.com/mamedev/mame/commit/078e954270872fd65a7d6d9d7a41c3c73346d526>. See the comments on that commit for why both the new and the old check are broken (although the old one might work for gentoo).
The attached patch should work with either version of libstdc++ (or you could create a patch that reverts the commit linked above if you prefer that route).
Comment 1 Mr. Bones. (RETIRED) gentoo-dev 2016-05-10 14:41:14 UTC
what is this?  a bug with a patch attached that works around a problem?  I'd almost forgotten what such a thing looked like.

in portage.  thanks for the bug report and patch.
Comment 2 Alexander Miller 2016-06-30 16:30:04 UTC
Now also fixed upstream (in 0.175).