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 321990 - Error building libgnomevfs/libgnomevfsmm/uri.cc with SGI, Tru64 UNIX, Sun C++ compilers
Error building libgnomevfs/libgnomevfsmm/uri.cc with SGI, Tru64 UNIX, Sun C++...
Status: RESOLVED WONTFIX
Product: gnome-vfsmm
Classification: Deprecated
Component: general
git master
Other Solaris
: Normal normal
: ---
Assigned To: gnome-vfsmm-maint
gnome-vfsmm-maint
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2005-11-21 01:10 UTC by The Written Word
Modified: 2011-02-07 05:06 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
new unwrap_const and TypeTraits_const interfaces for broken compilers (6.96 KB, patch)
2006-12-22 09:22 UTC, The Written Word
none Details | Review
fixes for compilers not able to disambiguate const template parms; static_cast removal for same broken compilers (33.52 KB, patch)
2006-12-22 09:31 UTC, The Written Word
none Details | Review

Description The Written Word 2005-11-21 01:10:25 UTC
Version details: 2.10.0
Distribution/Version: 10

I encounter the following error building libgnomevfs/libgnomevfsmm/uri.cc with
the SGI, Tru64 UNIX, and Sun C++ compilers.

From the Tru64 UNIX compiler:
 cxx -DHAVE_CONFIG_H -DG_LOG_DOMAIN=\"libgnomevfsmm\" -I../../libgnomevfs
-I../../libgnomevfs -pthread -DORBIT2=1 -I/opt/TWWfsw/libglib26/include
-I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/libsigc++20/include
-I/opt/TWWfsw/libsigc++20/lib/include -I/opt/TWWfsw/libglibmm26/include
-I/opt/TWWfsw/libglibmm26/lib/include -I/opt/TWWfsw/gnome210/include/gnome-vfs
-I/opt/TWWfsw/gnome210/include/bonobo-activation
-I/opt/TWWfsw/gnome210/include/libbonobo -I/opt/TWWfsw/gnome210/include/gconf
-I/opt/TWWfsw/gnome210/include -I/opt/TWWfsw/gnome210/include/gnome-vfs-module
-I/opt/TWWfsw/gettext014/include -I/opt/TWWfsw/libiconv19/include -O2 -msym
-readonly_strings -timplicit_local -model ansi -D__USE_STD_IOSTREAM -c uri.cc 
-DPIC -o .libs/uri.o
cxx: Error: uri.cc, line 46: invalid type conversion
  GnomeVFSResult result =
gnome_vfs_get_file_info_uri(const_cast<GnomeVFSURI*>(gobj()), file_info,
static_cast<GnomeVFSFileInfoOptions>(options));
---------------------------------------------------------------------------------------------------^
cxx: Error: uri.cc, line 248: more than one instance of overloaded function
          "Glib::unwrap" matches the argument list:
            function template "Glib::unwrap(const Glib::RefPtr<T_CppObject> &)"
            function template "Glib::unwrap(const Glib::RefPtr<const T> &)"
            argument types are: (const Glib::RefPtr<const Gnome::Vfs::Uri>)
  return gnome_vfs_uri_equal(const_cast<GnomeVFSURI*>(gobj()), Glib::unwrap(uri));
---------------------------------------------------------------^
cxx: Error: uri.cc, line 265: more than one instance of overloaded function
          "Glib::unwrap" matches the argument list:
            function template "Glib::unwrap(const Glib::RefPtr<T_CppObject> &)"
            function template "Glib::unwrap(const Glib::RefPtr<const T> &)"
            argument types are: (const Glib::RefPtr<const Gnome::Vfs::Uri>)
  return gnome_vfs_uri_is_parent(const_cast<GnomeVFSURI*>(gobj()),
Glib::unwrap(possible_child), static_cast<int>(recursive));
-------------------------------------------------------------------^
cxx: Info: 3 errors detected in the compilation of "uri.cc".
gmake[1]: *** [uri.lo] Error 1
gmake[1]: Leaving directory
`/opt/build/gnome-vfsmm-2.10.0/libgnomevfs/libgnomevfsmm'

From the SGI compiler:
 CC -DHAVE_CONFIG_H -DG_LOG_DOMAIN=\"libgnomevfsmm\" -I../../libgnomevfs
-I../../libgnomevfs -D_REENTRANT -DORBIT2=1 -I/opt/TWWfsw/libglib26/include
-I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/libsigc++20/include
-I/opt/TWWfsw/libsigc++20/lib/include -I/opt/TWWfsw/libglibmm26/include
-I/opt/TWWfsw/libglibmm26/lib/include -I/opt/TWWfsw/gnome210/include/gnome-vfs
-I/opt/TWWfsw/gnome210/include/bonobo-activation
-I/opt/TWWfsw/gnome210/include/libbonobo -I/opt/TWWfsw/gnome210/include/gconf
-I/opt/TWWfsw/gnome210/include -I/opt/TWWfsw/gnome210/include/gnome-vfs-module
-I/opt/TWWfsw/gettext014/include -I/opt/TWWfsw/libiconv19/include -Wl,-woff,84
-Wl,-woff,85 -woff 1429 -use_readonly_const -G0 -rdata_shared
-DEBUG:optimize_space=ON -O2 -OPT:Olimit=0 -c uri.cc  -DPIC -o .libs/uri.o
cc-1168 CC: ERROR File = uri.cc, Line = 46
  The indicated type conversion is invalid.

    GnomeVFSResult result =
gnome_vfs_get_file_info_uri(const_cast<GnomeVFSURI*>(gobj()), file_info,
static_cast<GnomeVFSFileInfoOptions>(options));
                                                                               
                     ^

cc-1282 CC: ERROR File = uri.cc, Line = 248
  More than one instance of overloaded function "Glib::unwrap" matches the
          argument list.

            Function symbol function template
                      "Glib::unwrap(const Glib::RefPtr<T_CppObject> &)" is
                      ambiguous by inheritance.
            Function symbol function template
                      "Glib::unwrap(const Glib::RefPtr<const T> &)" is
                      ambiguous by inheritance.
            The argument types are:  (const Glib::RefPtr<const Gnome::Vfs::Uri>
                      ).
    return gnome_vfs_uri_equal(const_cast<GnomeVFSURI*>(gobj()), Glib::unwrap(uri));
                                                                 ^

cc-1282 CC: ERROR File = uri.cc, Line = 265
  More than one instance of overloaded function "Glib::unwrap" matches the
          argument list.

            Function symbol function template
                      "Glib::unwrap(const Glib::RefPtr<T_CppObject> &)" is
                      ambiguous by inheritance.
            Function symbol function template
                      "Glib::unwrap(const Glib::RefPtr<const T> &)" is
                      ambiguous by inheritance.
            The argument types are:  (const Glib::RefPtr<const Gnome::Vfs::Uri>
                      ).
    return gnome_vfs_uri_is_parent(const_cast<GnomeVFSURI*>(gobj()),
Glib::unwrap(possible_child), static_cast<int>(recursive));
                                                                     ^

3 errors detected in the compilation of "uri.cc".
gmake[4]: *** [uri.lo] Error 1
gmake[4]: Leaving directory
`/opt/build/gnome-vfsmm-2.10.0/libgnomevfs/libgnomevfsmm'

From the Sun compiler:
 CC -DHAVE_CONFIG_H -DG_LOG_DOMAIN=\"libgnomevfsmm\" -I../../libgnomevfs
-I../../libgnomevfs -mt -DORBIT2=1 -I/opt/TWWfsw/libglib26/include
-I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/libsigc++20/include
-I/opt/TWWfsw/libsigc++20/lib/include -I/opt/TWWfsw/libglibmm26/include
-I/opt/TWWfsw/libglibmm26/lib/include -I/opt/TWWfsw/gnome210/include/gnome-vfs
-I/opt/TWWfsw/gnome210/include/bonobo-activation
-I/opt/TWWfsw/gnome210/include/libbonobo -I/opt/TWWfsw/gnome210/include/gconf
-I/opt/TWWfsw/gnome210/include -I/opt/TWWfsw/gnome210/include/gnome-vfs-module
-I/opt/TWWfsw/gettext014/include -I/opt/TWWfsw/libiconv19/include -xO2
-xtarget=generic -xarch=v8 -c uri.cc  -KPIC -DPIC -o .libs/uri.o
"uri.cc", line 46: Error: Using static_cast to convert from
Gnome::Vfs::FileInfoOptions to GnomeVFSFileInfoOptions not allowed.
"uri.cc", line 248: Error: Overloading ambiguity between
"Glib::unwrap<Gnome::Vfs::Uri>(const Glib::RefPtr<const Gnome::Vfs::Uri>&)" and
"Glib::unwrap<const Gnome::Vfs::Uri>(const Glib::RefPtr<const Gnome::Vfs::Uri>&)".
"uri.cc", line 265: Error: Overloading ambiguity between
"Glib::unwrap<Gnome::Vfs::Uri>(const Glib::RefPtr<const Gnome::Vfs::Uri>&)" and
"Glib::unwrap<const Gnome::Vfs::Uri>(const Glib::RefPtr<const Gnome::Vfs::Uri>&)".
3 Error(s) detected.
gmake[4]: *** [uri.lo] Error 1
gmake[4]: Leaving directory
`/opt/build/gnome-vfsmm-2.10.0/libgnomevfs/libgnomevfsmm'
Comment 1 The Written Word 2005-11-21 04:15:34 UTC
The problem with line #46 might be a compiler bug. The following small test
program fails on the above compilers:
typedef enum {
  GNOME_VFS_FILE_INFO_DEFAULT = 0
} GnomeVFSFileInfoOptions;

enum FileInfoOptions
{
  FILE_INFO_DEFAULT = 0
};

extern "C" {
  void file_info (GnomeVFSFileInfoOptions options);
}

void
func (FileInfoOptions options) {
  file_info (static_cast<GnomeVFSFileInfoOptions>(options));
}
Comment 2 Murray Cumming 2005-11-22 08:24:01 UTC
> "uri.cc", line 248: Error: Overloading ambiguity between
> "Glib::unwrap<Gnome::Vfs::Uri>(const Glib::RefPtr<const Gnome::Vfs::Uri>&)" and
> "Glib::unwrap<const Gnome::Vfs::Uri>(const Glib::RefPtr<const Gnome::Vfs::Uri>&)".

We experienced this already in gtkmm. Using __CONVERT_CONST_REFPTR_TO_P_SUN
instead of the normal conversion should help. For instance:
http://cvs.gnome.org/viewcvs/gtkmm/tools/m4/convert_gtk.m4?view=markup
Comment 3 Murray Cumming 2005-11-22 08:25:44 UTC
>The problem with line #46 might be a compiler bug

Yes, probably, but you should be able to work around it by using a C-style cast.
Just add a comment in the patch saying why we are doing it, please.
Comment 4 Murray Cumming 2005-12-05 12:15:58 UTC
Did this help?
Comment 5 The Written Word 2005-12-06 13:37:01 UTC
The C-style cast works. We've already tested a patch for Studio 8 from Sun.
Haven't looked into __CONVERT_CONST_REFPTR_TO_P_SUN yet. Will try to soon.
Comment 6 Murray Cumming 2006-02-10 11:46:59 UTC
If you could try that, it would be nice to make the change in cvs and close this bug.
Comment 7 The Written Word 2006-03-07 06:29:53 UTC
Ok, will try to get to it soon. Sun should have official patches soon as well.
Comment 8 The Written Word 2006-12-02 15:44:53 UTC
Some updates on these two bugs (static_cast and Glib::unwrap ambiguities):

o static_cast needs to be removed at quite a lot of other places, too. I didn't
  check if these were all enum related casts.

o The overload ambiguity bug in the Sun compiler has been filed as

  4886310 Overloading ambiguity error with usage of template function with const vector

  Unfortunately I don't have access to the bug description and activity, but it
  is supposedly fixed in the latest compiler patches. Still a workaround is
  needed for the other broken compilers as well.

o The workaround is to explicitly instantiate the function template with the
  proper argument. There seems to be another bug in the game requiring full 
  Namespace resolution. For example:

 bool Uri::equal(const Glib::RefPtr<const Uri>& uri) const
 {
-  return gnome_vfs_uri_equal(const_cast<GnomeVFSURI*>(gobj()), Glib::unwrap(uri));
+  return gnome_vfs_uri_equal(const_cast<GnomeVFSURI*>(gobj()), Glib::unwrap<Gnome::Vfs::Uri>(uri));
 }

  Perhaps some m4 conversion tricks would be able to get the template parameter
  as an argument to Glib::unwrap.

o glibmm has similar Glib::unwrap (indirect) issues, e.g. some header files need
  to explicitely instanciate the proper template, too, to assist the compiler in
  its choice.

When I get it to build on the remaining platforms, I can post a patch here, but it would be against the gtkmmproc generated files.
Comment 9 The Written Word 2006-12-22 09:22:13 UTC
Created attachment 78780 [details] [review]
new unwrap_const and TypeTraits_const interfaces for broken compilers

In order to fix this bug (or work around it) I had to patch glibmm (I'm using glibmm-2.6.1). The problems are that

a) Not all broken implementations are caught by the tests for 
   GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS
b) the __CONVERT_CONST_REFPTR_TO_P_SUN method works by casting away the
   const,but that is only possible if the qualifer is at the top level type
   specification, e.g. const Uri* can be const_cast to Uri*, but RefPtr<const
   Foo> not anymore.

The tests for a) test whether the compiler can disambiguate const qualifiers in templated classes. That is needed for the TypeTraits class. But the Glib::unwrap function can still be broken, for example the DEC compiler copes well with templated classes, but not with templated functions. The tests need to probe for functions, too, or assuming that there are no implementations that have working functions, but broken classes, only test for templated functions.

In order to disambiguate Glib::unwrap for the broken compilers I resorted to renaming the function to Glib::unwrap_const for the ambiguous specialisations with const qualifiers. The compilers with proper disambiguation support have both the *_const and the normal specialization. Similar for TypeTraits.
Comment 10 The Written Word 2006-12-22 09:31:37 UTC
Created attachment 78781 [details] [review]
fixes for compilers not able to disambiguate const template parms; static_cast removal for same broken compilers

After applying the previous pacth to glibmm gnomevfsmm can use the *_const interfaces. The next patch includes the following:

o changes to tools/m4/convert_gnome_vfsmm.m4 to include const_casts and
  unwrap_const. The gmmproc generated bits are not included to keep patch noise
  low.
o quite a lot of static_cast to simple C style cast changes (see comment #3)
  needed for Sun's compiler.
o explicit parameters for defining ListHandleUris including TypeTraits_const.

Using both patches allow glibmm & gnomvfsmm to build on both solaris and osf. irix fails out on a rather unfixable double-definition compiler bug.
Comment 11 Murray Cumming 2007-01-11 18:01:42 UTC
Many thanks.

> The tests for a) test whether the compiler can disambiguate const qualifiers in
> templated classes. That is needed for the TypeTraits class. But the
> Glib::unwrap function can still be broken, for example the DEC compiler copes
> well with templated classes, but not with templated functions. The tests need
> to probe for functions, too, or assuming that there are no implementations that
> have working functions, but broken classes, only test for templated functions

I'd like to see a test for this, so we can avoid adding code that isn't necessary on other compilers. I don't see any changes to the test in these two patches.
Comment 12 Murray Cumming 2007-01-12 10:37:30 UTC
Also, maybe I'm missing it in your text above, but I don't see why we can't just specify the template specialization (e.g. Glib::unwrap<const TheClass*>(thecppinstance)), as suggested in comment #2:
http://bugzilla.gnome.org/show_bug.cgi?id=321990#c2
Comment 13 The Written Word 2007-01-12 11:22:26 UTC
(In reply to comment #11)
> > The tests for a) test whether the compiler can disambiguate const qualifiers in
> > templated classes. That is needed for the TypeTraits class. But the
> > Glib::unwrap function can still be broken, for example the DEC compiler copes
> > well with templated classes, but not with templated functions. The tests need
> > to probe for functions, too, or assuming that there are no implementations that
> > have working functions, but broken classes, only test for templated functions
> 
> I'd like to see a test for this, so we can avoid adding code that isn't
> necessary on other compilers. I don't see any changes to the test in these two
> patches.

No, there is no test in the patches sent, this was just a comment. I don't think you can avoid any code by a smarter test, the comment just says that the tests are giving false positives for DEC.

(In reply to comment #12)
> Also, maybe I'm missing it in your text above, but I don't see why we can't
> just specify the template specialization (e.g. Glib::unwrap<const
> TheClass*>(thecppinstance)), as suggested in comment #2:
> http://bugzilla.gnome.org/show_bug.cgi?id=321990#c2

See comment #9 part b)

Comment 14 Fabio Durán Verdugo 2011-02-07 05:06:52 UTC
gnome-vfsmm development has been stalled and it has been unmaintained for a few
years now.
Maintainers don't have future development plan so i am closing bugs as WONTFIX.
Please feel free to reopen the bugs in future if anyone takes the responsibility for active development.