GNOME Bugzilla – Bug 585027
Glib::Date copy constructor triggers critical warnings
Last modified: 2009-06-22 17:44:25 UTC
The Glib::Date copy constructor assumes that all Date objects are initialized to a valid date, since it does the following: g_date_clear(&gobject_, 1); g_date_set_julian(&gobject_, other.get_julian()); if you do something as simple as this: Glib::Date date; Glib::Date other (date); you'll get the following warnings: GLib-CRITICAL **: g_date_set_julian: assertion `g_date_valid_julian (j)' failed
Created attachment 136076 [details] [review] Patch to check for invalid date in copy constructor and assignment operator I don't understand why one would want to construct a new date from an invalid date but still this patch would fix it so that this would be possible. Do you want this committed?
(In reply to comment #1) > I don't understand why one would want to construct a new date from an invalid > date but I think you were referring to the fact that copy constructors are used whenever an object is passed or returned by value and so the importance of getting it right. I was just researching a bit and the following link suggests that exceptions be thrown when a constructor fails: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.17 Would something similar be necessary in this case?
If the patch fixed crashes then please do commit.
Likewise if it causes a critical warning.
Committed to master: 2009-06-22 José Alburquerque <jaalburqu@svn.gnome.org> * glib/src/date.ccg: Check for an invalid date in copy constructor and assignment operator. Fixes bug #585027.
Also applied to glibmm-2-18 and glibmm-2-20. Will apply things to glibmm-2-20 instead of master next time.
It's fine to commit things to master. Nothing should be in glibmm-2-20 that is not in master.
Understood.