GNOME Bugzilla – Bug 709963
Cannot compile with clang
Last modified: 2013-12-01 09:23:02 UTC
In file included from /usr/include/gtkmm-3.0/gtkmm/drawingarea.h:28: In file included from /usr/include/gtkmm-3.0/gtkmm/widget.h:56: /usr/include/giomm-2.4/giomm/actiongroup.h:618:50: error: const_cast from 'const GActionGroup *' (aka 'const _GActionGroup *') to 'GAction *' (aka '_GAction *') is not allowed g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj())); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gmessages.h:337:18: note: expanded from macro 'g_return_if_fail' if G_LIKELY(expr) { } else \ ^ /usr/include/glib-2.0/glib/gmacros.h:318:25: note: expanded from macro 'G_LIKELY' #define G_LIKELY(expr) (expr) Current Archlinux, glibmm 2.38.0-1 $ clang -v clang version 3.3 (tags/RELEASE_33/final) Target: x86_64-unknown-linux-gnu Thread model: posix
Identical error observed on MacPorts while attempting to upgrade from glibmm 2.36.2 to 2.38.0. This bug is blocking any further updates on the MacPorts platform. Mac OS X 10.8.5 Xcode 5.0 Build version 5A1413 Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.5.0 Thread model: posix
const_cast<GAction*>(gobj()) in Gio::ActionGroup is obviously wrong. I made some tests with gcc version 4.7.3. It's not very good at detecting errors in function templates. This error is not detected unless the template is instantiated when compiling a function that calls the templated function. I thought that perhaps the error is not detected because it's part of an expression that depends on a template parameter (indirectly via type_glib_variant). But no, not even a statement such as GAction* action = const_cast<GAction*>(gobj()); is reported as an error unless the templated function is instantiated. I suspect that the statement g_return_if_fail( g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj())); is a left-over from a copy-paste operation, and shall be deleted.
Yes, I have just removed that: https://git.gnome.org/browse/glibmm/commit/?id=c619be2fadae1b5a87151db0b0adddf55584084a Could someone please confirm that it fixes the build for them?
Yes, this fixes the build for the MacPorts case. Build tested on buildbots for Mac OS X 10.6, 10.7, 10.8 covering Apple clang versions from 3.0 through 5.0. Thanks.
This fixes the build in my case, aswell.
The fix is included in glibmm 2.38.1.