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 395572 - overloading ambiguity in printoptions.cc with Sun Workshop 11 CC
overloading ambiguity in printoptions.cc with Sun Workshop 11 CC
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: build
2.10.x
Other opensolaris
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2007-01-11 21:19 UTC by Tim Mooney
Modified: 2007-01-17 19:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch that attempts to fix this (1.97 KB, patch)
2007-01-11 22:27 UTC, Marko Anastasov
none Details | Review
patch 2, with template specialization (2.46 KB, patch)
2007-01-12 15:27 UTC, Marko Anastasov
none Details | Review
third attempt (2.61 KB, patch)
2007-01-12 20:11 UTC, Marko Anastasov
none Details | Review
another take on template specialization (2.12 KB, patch)
2007-01-12 22:35 UTC, Marko Anastasov
none Details | Review

Description Tim Mooney 2007-01-11 21:19:57 UTC
OS: x86_64-sun-solaris2.10
Toolchain: Sun Workshop 11 C & C++, with all relevant updates

I've built all of the gtkmm-2.10.6 prereqs (glib, gtk, cairo, glibmm, sigc++, etc.) using Sun's Workshop 11 toolchain.

While attempting to build gtkmm-2.10.6, the C++ compiler complains about overloading ambiguities in printoptions.cc:

 CC -DHAVE_CONFIG_H -DG_LOG_DOMAIN=\"gtkmm\" -I../../gtk -I../../gtk -I../../pango -I../../pango -I../../atk -I../../atk -I../../gdk -I../../gdk -I../../gtk -I../../gtk -I/local/gnu/include/glibmm-2.4 -I/local/gnu/lib/64/glibmm-2.4/include -I/local/gnu/include/sigc++-2.0 -I/local/gnu/lib/64/sigc++-2.0/include -I/local/gnu/include/glib-2.0 -I/local/gnu/lib/64/glib-2.0/include -I/local/include/cairomm-1.0 -I/local/include/cairo -I/local/gnu/include/gtk-2.0 -I/local/gnu/lib/64/gtk-2.0/include -I/local/gnu/include/atk-1.0 -I/local/gnu/include/pango-1.0 -I/local/gnu/include/gtk-unix-print-2.0 -mt -I/local/gnu/include/glib-2.0 -I/local/gnu/lib/64/glib-2.0/include -I/local/gnu/include -I/local/include -xO3 -KPIC -xtarget=native -xarch=amd64 -I/local/gnu/include -I/local/include -c printoperation.cc  -KPIC -DPIC -o .libs/printoperation.o
"printoperation.cc", line 90: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)" and "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".
"printoperation.cc", line 91: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)" and "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)".
"printoperation.cc", line 104: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)" and "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".
"printoperation.cc", line 105: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)" and "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)".
"printoperation.cc", line 106: Warning (Anachronism): Formal argument done_cb of type extern "C" void(*)(_GtkPageSetup*,void*) in call to gtk_print_run_page_setup_dialog_async(_GtkWindow*, _GtkPageSetup*, _GtkPrintSettings*, extern "C" void(*)(_GtkPageSetup*,void*), void*) is being passed void(*)(_GtkPageSetup*,void*).
"printoperation.cc", line 598: Warning (Anachronism): Assigning void(*)(void*,void*) to extern "C" void(*)(void*,void*).
"printoperation.cc", line 623: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*,GtkPrintOperationResult) to extern "C" void(*)(_GtkPrintOperation*,GtkPrintOperationResult).
"printoperation.cc", line 624: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*,_GtkPrintContext*) to extern "C" void(*)(_GtkPrintOperation*,_GtkPrintContext*).
"printoperation.cc", line 625: Warning (Anachronism): Assigning int(*)(_GtkPrintOperation*,_GtkPrintContext*) to extern "C" int(*)(_GtkPrintOperation*,_GtkPrintContext*).
"printoperation.cc", line 626: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*,_GtkPrintContext*,int,_GtkPageSetup*) to extern "C" void(*)(_GtkPrintOperation*,_GtkPrintContext*,int,_GtkPageSetup*).
"printoperation.cc", line 627: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*,_GtkPrintContext*,int) to extern "C" void(*)(_GtkPrintOperation*,_GtkPrintContext*,int).
"printoperation.cc", line 628: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*,_GtkPrintContext*) to extern "C" void(*)(_GtkPrintOperation*,_GtkPrintContext*).
"printoperation.cc", line 629: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*) to extern "C" void(*)(_GtkPrintOperation*).
"printoperation.cc", line 630: Warning (Anachronism): Assigning _GtkWidget*(*)(_GtkPrintOperation*) to extern "C" _GtkWidget*(*)(_GtkPrintOperation*).
"printoperation.cc", line 631: Warning (Anachronism): Assigning void(*)(_GtkPrintOperation*,_GtkWidget*) to extern "C" void(*)(_GtkPrintOperation*,_GtkWidget*).
"printoperation.cc", line 632: Warning (Anachronism): Assigning int(*)(_GtkPrintOperation*,_GtkPrintOperationPreview*,_GtkPrintContext*,_GtkWindow*) to extern "C" int(*)(_GtkPrintOperation*,_GtkPrintOperationPreview*,_GtkPrintContext*,_GtkWindow*).
4 Error(s) and 12 Warning(s) detected.
gmake[5]: *** [printoperation.lo] Error 1
gmake[5]: Leaving directory `/local/src/RPM/BUILD/gtkmm-2.10.6/gtk/gtkmm'
gmake[4]: *** [all-recursive] Error 1
gmake[4]: Leaving directory `/local/src/RPM/BUILD/gtkmm-2.10.6/gtk/gtkmm'
gmake[3]: *** [all-recursive] Error 1


My C++ is weak, so I'm not able to make any useful suggestion about how the
errors might be avoided.
Comment 1 Marko Anastasov 2007-01-11 22:27:58 UTC
Created attachment 80087 [details] [review]
patch that attempts to fix this

I was wondering how come that this is the only file being reported, but actualy this is the only place (in .ccg files) where unwrap is called for a const RefPtr<const T>. Such RefPtr and an unwrap() appear in style.ccg, in set_bg_pixmap(), starting at line 173, but it is first cast_const() to a RefPtr<T> and then that new pointer is passed to unwrap_copy(). Which is a different case.

So my guess is that if these unwrap() calls are first called to return to an explicit const GtkSomeType*, then these errors would not be reported.
Comment 2 Tim Mooney 2007-01-12 00:51:08 UTC
I eventually figured out how to regenerate the gtk/gtkmm/printoperations.cc from the source file, and the error has now moved:

 CC -DHAVE_CONFIG_H -DG_LOG_DOMAIN=\"gtkmm\" -I../../gtk -I../../gtk -I../../pango -I../../pango -I../../atk -I../../atk -I../../gdk -I../../gdk -I../../gtk -I../../gtk -I/local/gnu/include/glibmm-2.4 -I/local/gnu/lib/64/glibmm-2.4/include -I/local/gnu/include/sigc++-2.0 -I/local/gnu/lib/64/sigc++-2.0/include -I/local/gnu/include/glib-2.0 -I/local/gnu/lib/64/glib-2.0/include -I/local/include/cairomm-1.0 -I/local/include/cairo -I/local/gnu/include/gtk-2.0 -I/local/gnu/lib/64/gtk-2.0/include -I/local/gnu/include/atk-1.0 -I/local/gnu/include/pango-1.0 -I/local/gnu/include/gtk-unix-print-2.0 -mt -I/local/gnu/include/glib-2.0 -I/local/gnu/lib/64/glib-2.0/include -I/local/gnu/include -I/local/include -xO3 -KPIC -xtarget=native -xarch=amd64 -I/local/gnu/include -I/local/include -c printoperation.cc  -KPIC -DPIC -o .libs/printoperation.o
"printoperation.cc", line 87: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)" and "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".
"printoperation.cc", line 88: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)" and "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)".
"printoperation.cc", line 105: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)" and "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".
"printoperation.cc", line 106: Error: Overloading ambiguity between "Glib::unwrap<Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)" and "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)".


Lines 87 & 88 are:

  const GtkPageSetup* c_page_setup = Glib::unwrap(page_setup);
  const GtkPrintSettings* c_print_settings = Glib::unwrap(print_settings);


Comment 3 Murray Cumming 2007-01-12 10:34:08 UTC
Could you please try specifying a template specialization, to avoid the error like so:

Glib::unwrap<const GtkPageSetup*>(page_setup)

If you make a new patch, please add comments next to the code explaining why that has been done, so it will not be removed by someone in the future.

Comment 4 Marko Anastasov 2007-01-12 15:27:01 UTC
Created attachment 80113 [details] [review]
patch 2, with template specialization

Tim, can you try with this patch?
Comment 5 Marko Anastasov 2007-01-12 15:29:17 UTC
Don't know how that happenned, I just typed 'patch 2' and it became a link to something. Please ignore that one.
Comment 6 Tim Mooney 2007-01-12 17:34:32 UTC
Thanks for making the patch Marko.

Unfortunately, still no joy:

"printoperation.cc", line 91: Error: Overloading ambiguity between "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)" and "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".
"printoperation.cc", line 94: Error: Overloading ambiguity between "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)" and "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)".
"printoperation.cc", line 115: Error: Overloading ambiguity between "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)" and "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".
"printoperation.cc", line 118: Error: Overloading ambiguity between "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)" and "Glib::unwrap<const Gtk::PrintSettings>(const Glib::RefPtr<const Gtk::PrintSettings>&)".


I have regenerated printoperation.cc, and it includes Marko's second patch.
Line 91 is the last line I show:


  // Specify the exact type with template specialization, to avoid possible
  // ambiguities between the const and non-const versions of unwrap reported
  // by some compilers:
  const GtkPageSetup* c_page_setup =
    Glib::unwrap<const PageSetup>(page_setup);
Comment 7 Marko Anastasov 2007-01-12 20:11:10 UTC
Created attachment 80136 [details] [review]
third attempt

Ok, try with this one. I kinda don't like it, but maybe it'll solve the problem. Here, the idea is to do eg:

Glib::RefPtr<PageSetup> page_setup_unconst =
    Glib::RefPtr<PageSetup>::cast_const(page_setup);

and then use that new one with unwrap().
Comment 8 Murray Cumming 2007-01-12 20:41:12 UTC
> "printoperation.cc", line 91: Error: Overloading ambiguity between
> "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)"
> and
> "Glib::unwrap<const Gtk::PageSetup>(const Glib::RefPtr<const Gtk::PageSetup>&)".

Well this makes no sense to me. They are the same, though I guess it thinks it is referring to these two partial template specializations from glibmm's wrap.h:

template <class T> inline
const typename T::BaseObjectType* unwrap(const T* ptr)
{
  return (ptr) ? ptr->gobj() : 0;
}

template <class T> inline
typename T::BaseObjectType* unwrap(const Glib::RefPtr<T>& ptr)
{
  return (ptr) ? ptr->gobj() : 0;
}

We already use this specifying-the-specialization trick elsewhere in gtkmm, using the __CONVERT_CONST_REFPTR_TO_P_SUN() macro in our .m4 conversion files, but I wonder why it isn't work for this example:

# The Sun Forte compiler doesn't seem to be able to handle these, so we are using the altlernative,  __CONVERT_CONST_REFPTR_TO_P_SUN.
# The Sun compiler gives this error, for instance:
#  "widget.cc", line 4463: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Window>(const Glib::RefPtr<const Gdk::Window>&)" and
# "Glib::unwrap<const Gdk::Window>(const Glib::RefPtr<const Gdk::Window>&)".
#
define(`__CONVERT_CONST_REFPTR_TO_P_SUN',`const_cast<$`'2>(Glib::unwrap<$1>($`'3))')

You might even be able to use that macro in the .ccg file.


Comment 9 Tim Mooney 2007-01-12 22:19:36 UTC
Marko's patch #3 worked.  The compile is now proceeding onward.  Thanks much to both of you for your efforts!
Comment 10 Marko Anastasov 2007-01-12 22:35:17 UTC
Created attachment 80154 [details] [review]
another take on template specialization

Glad to hear :).

Can you also try with this one, please? It's similar to the second one, only simpler. I just added the specialization to <GtkmmType> to the original code, instead of having a separate call with a specialization to <const GtkmmType>.
Comment 11 Tim Mooney 2007-01-16 23:31:48 UTC
Sorry for the delay.  I tested patch #4, and it also works just fine.
Comment 12 Murray Cumming 2007-01-17 14:15:45 UTC
Looks good, though I'm surprised that it works.
Comment 13 Marko Anastasov 2007-01-17 15:32:23 UTC
Changes as in #4 committed.
Comment 14 Murray Cumming 2007-01-17 19:55:17 UTC
Many thanks, Marko.