After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 709963 - Cannot compile with clang
Cannot compile with clang
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: io
2.38.x
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2013-10-12 05:04 UTC by Johannes Meng
Modified: 2013-12-01 09:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Johannes Meng 2013-10-12 05:04:19 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
Comment 1 David Evans 2013-10-12 16:07:36 UTC
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
Comment 2 Kjell Ahlstedt 2013-10-13 08:25:32 UTC
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.
Comment 3 Murray Cumming 2013-10-14 08:38:12 UTC
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?
Comment 4 David Evans 2013-10-14 16:32:08 UTC
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.
Comment 5 Johannes Meng 2013-10-14 19:11:57 UTC
This fixes the build in my case, aswell.
Comment 6 Kjell Ahlstedt 2013-12-01 09:23:02 UTC
The fix is included in glibmm 2.38.1.