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 132300 - G++-3.4 Prerelease: Private copy constructor for Glib::ConstructParams.
G++-3.4 Prerelease: Private copy constructor for Glib::ConstructParams.
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.4
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-01-23 13:45 UTC by Matthew Tuck
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Matthew Tuck 2004-01-23 13:45:08 UTC
The following code:

#include <gtkmm/treemodelcolumn.h>
#include <gtkmm/treeviewcolumn.h>

int main(int argc, char *argv[]) {
  
  Gtk::TreeModelColumn<int> col;
  Gtk::TreeViewColumn col2("A", col);
  
}

gives these errors in G++-3.4:

/usr/include/gtkmm-2.0/glibmm/object.h: In constructor
`Gtk::TreeViewColumn::TreeViewColumn(const Glib::ustring&, const
Gtk::TreeModelColumn<ColumnType>&) [with T_ModelColumnType = int]':
private2.cc:7:   instantiated from here
/usr/include/gtkmm-2.0/glibmm/object.h:76: error:
`Glib::ConstructParams::ConstructParams(const Glib::ConstructParams&)' is
private
/usr/include/gtkmm-2.0/gtkmm/treeviewcolumn.h:674: error: within this context

apparently this is because of this code:

template <class T_ModelColumnType>
TreeViewColumn::TreeViewColumn(const Glib::ustring& title,
                               const TreeModelColumn<T_ModelColumnType>&
column)
:
  Glib::ObjectBase(0), // not (yet) a custom class
  Gtk::Object(Glib::ConstructParams(class_init_(), "title", title.c_str(),
(char*) 0))
{
  pack_start(column, true /* expand */);
}

Apparently the Glib::ConstructParams needs to be copyable.  This is
something to do with passing a reference to a temporary.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12226 was mentioned as related.

I imagine this is quite common in Gtkmm but I think this is the only
instance in a header as its a template.

Not sure about workarounds here if copy construction is unacceptable,
perhaps making the params into a member variable would solve the problem.

Here's a test case of this, works in 3.2/3.3 but not 3.4:

struct A
{
  A(const char* p, ...);
private:
  A(const A&);
};
 
struct B
{
  B(const A&);
};
 
int main(int argc, char *argv[]) {
   
  B b( A("title", (char*) 0) );
   
}
Comment 1 Murray Cumming 2004-01-27 10:47:29 UTC
Thanks. Let's try to deal with these before the API freeze, because we
might not be able to deal with them afterwards.:
http://www.gnome.org/start/2.5/bindings/
Comment 2 Matthew Tuck 2004-01-27 15:19:37 UTC
danielk didn't mention it here, but he did some stuff with this,
introducing a copy constructor, not tested yet.

You probably don't actually need to write the constructor though, just
make it public.  Because G++ probably optimises it out, it probably
never gets actually called, just checked.  So it might work like the
private constructor trick, you don't need to supply the body if it's
never used.  Might not be a good idea to rely on this though.
Comment 3 Murray Cumming 2004-02-27 00:00:22 UTC
Any chance of a patch?
Comment 4 Murray Cumming 2004-03-13 15:17:17 UTC
I have added the public copy constructor in cvs. Thanks.
Comment 5 Daniel Elstner 2004-05-13 15:48:36 UTC
As it happens I had already written a little patch to fix this when Matthew
first told me about the problem, which then got lost due to my long absence from
gtkmm development.

Anyway, I stumbled over this issue again today and noticed that the current
solution doesn't implement the copy constructor properly, thus in effect relying
on the call being optimized away by the compiler.  To fix this pontential
problem, I now committed my older patch to both the glibmm and the gtkmm2 module:

2004-05-13  Daniel Elstner  <daniel.elstner@gmx.net>

	* glib/glibmm/object.{cc,h} (ConstructParams::ConstructParams):
	Implement the copy constructor in a way that actually works if used.
	Relying on the compiler to optimize it away is a bad idea. (#132300)