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 585027 - Glib::Date copy constructor triggers critical warnings
Glib::Date copy constructor triggers critical warnings
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2009-06-06 22:04 UTC by Jonathon Jongsma
Modified: 2009-06-22 17:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to check for invalid date in copy constructor and assignment operator (1.37 KB, patch)
2009-06-07 04:10 UTC, José Alburquerque
committed Details | Review

Description Jonathon Jongsma 2009-06-06 22:04:33 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
Comment 1 José Alburquerque 2009-06-07 04:10:42 UTC
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?
Comment 2 José Alburquerque 2009-06-07 16:39:46 UTC
(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?
Comment 3 Murray Cumming 2009-06-22 13:22:44 UTC
If the patch fixed crashes then please do commit.
Comment 4 Murray Cumming 2009-06-22 13:23:16 UTC
Likewise if it causes a critical warning.
Comment 5 José Alburquerque 2009-06-22 16:17:35 UTC
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.
Comment 6 José Alburquerque 2009-06-22 17:30:54 UTC
Also applied to glibmm-2-18 and glibmm-2-20.  Will apply things to glibmm-2-20 instead of master next time.
Comment 7 Murray Cumming 2009-06-22 17:41:45 UTC
It's fine to commit things to master. Nothing should be in glibmm-2-20 that is not in master.
Comment 8 José Alburquerque 2009-06-22 17:44:25 UTC
Understood.