Bug #1735

Ruby compiled with gcc 4.4.0: problems in date.rb

Added by be9 (Oleg Dashevskii) over 11 years ago. Updated over 9 years ago.

ruby -v:
ruby 1.8.6 (2009-06-08 patchlevel 369) [x86_64-linux]


I have a 64-bit ArchLinux system with gcc 4.4.0 and glibc 2.10.1. The distro itself ships 1.8.7, but I use REE which is 1.8.6-based. I'll illustrate the problem with stock Ruby 1.8.6-p369.

home:~% /opt/ruby-1.8.6-p369/bin/irb
irb(main):001:0> t =
=> Mon Jul 06 13:21:20 +0700 2009
irb(main):002:0> [t.year, t.month,]
=> [2009, 7, 6]
irb(main):003:0> d = Date.civil_to_jd(t.year, t.month,
=> 248077102
irb(main):004:0> Date.jd_to_civil(d)
=> [2075, -1, 37364]

I've run into this in my Rails app, namely with activesupport: and 1.year.from_now. The former raises ArgumentError with "invalid date", the latter just hangs.

The original post is on the REE group:
Other people with gcc 4.4.0 have confirmed this bug.

Here's valid behavior in 1.8.7:


=> "1.8.7"
=> 173
t =
=> Mon Jul 06 13:34:12 0700 2009
[t.year, t.month,]
=> [2009, 7, 6]
d = Date.civil_to_jd(t.year, t.month,
=> 2455019
=> [2009, 7, 6]


Updated by tadf (tadayoshi funaba) over 11 years ago

type ruby -e 'p 1867216.25'.
and try to re-build ruby without optimization.



Updated by phinze (Paul Hinze) over 11 years ago

Same issue here on fresh install of ArchLinux with gcc 4.4.1:

$ ruby -e 'p 1867216.25'

As per tadayoshi funaba's suggestion, I rebuilt ruby-1.8.6-p286 after editing the root Makefile like so:


And that solved the problem for me, at least in date.rb. I'm a little worried about what optimization bugs might be lurking elsewhere.

So is there something we should be doing to prevent this from happening to other users? I'm not very familiar with Ruby's C source but I'm willing to dive in if someone points me in the right direction.


Updated by nlugovoi (Nikolai Lugovoi) about 11 years ago

need to backport r23353 from branches/ruby_1_8 to 1.8.7 and 1.8.6


Updated by shyouhei (Shyouhei Urabe) about 11 years ago

  • Assignee set to wyhaines (Kirk Haines)

Revision r25801 backports this into 1.8.7.


Updated by wyhaines (Kirk Haines) over 10 years ago

  • Status changed from Open to Closed

This was fixed with the r28153, which also resolved Backport #2392 [ruby-core:26868]. The r25801 referenced in this ticket was already applied in r25871. My tests for this bug are passing, so I am closing the ticket.

Also available in: Atom PDF