From r|p|ey @end|ng |rom @t@t@@ox@@c@uk  Wed Oct 12 12:46:19 2022
From: r|p|ey @end|ng |rom @t@t@@ox@@c@uk (Prof Brian Ripley)
Date: Wed, 12 Oct 2022 11:46:19 +0100
Subject: [Rd] A potential POSIXlt->Date bug introduced in r-devel
In-Reply-To: <df276af2-5024-05dd-1ccb-96ffbf6e980b@stats.ox.ac.uk>
References: <CABzLhzzsnRCwM3LPM-z2T8YFO3bBcD7=iE3Hxx9rLdEUeAkk3g@mail.gmail.com>
 <25406.36513.13316.676488@stat.math.ethz.ch>
 <20221006164146.39f9b8e4@ECM-DTC-716.uniwa.uwa.edu.au>
 <df276af2-5024-05dd-1ccb-96ffbf6e980b@stats.ox.ac.uk>
Message-ID: <192501c4-46a4-ab4e-d908-8bde2eceda7b@stats.ox.ac.uk>

Confirmed on Fedora 36 which has a 32-bit time_t for an i686 compile.  I 
was a bit surprised that has not been changed, but gather Linux distros 
are preferring to drop ix86 than fix it.

There is a simple workaround, to configure R with 
--with-internal-tzcode, which always uses a 64-bit time_t.  Given that 
2038 is not that far away, avoiding 32-bit time_t is generally a very 
good idea (not just for people working with dates in 5881580!).

That test should not really be run on platforms with 32-bit time_t, but 
that is not currently known at R level.

On 06/10/2022 13:38, Prof Brian Ripley wrote:
> On 06/10/2022 09:41, Berwin A Turlach wrote:
>> G'day all,
>>
>> On Thu, 6 Oct 2022 10:15:29 +0200
>> Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>>
>>>>>>>> Davis Vaughan
>>>>>>>> ???? on Wed, 5 Oct 2022 17:04:11 -0400 writes:
>>
>>> ???? > # Weird, where is the `NA`?
>>> ???? > as.Date(x)
>>> ???? > #> [1] "2013-01-31" "1970-01-01" "2013-03-31"
>>> ???? > ```
>>>
>>> I agree that the above is wrong, i.e., a bug in current? R-devel.
>>
>> I have no intention of hijacking this thread, but I wonder whether this
>> is a good opportunity to mention that the 32 bit build of R-devel falls
>> over on my machine since 25 September.? It fails one of the regression
>> tests in reg-tests-1d.R.? The final lines of reg-tests-1d.Rout.fail
>> are:
>>
>>> tools::Rd2txt(rd, out <- textConnection(NULL, "w"), fragment = TRUE)
>>> stopifnot(any(as.character(rd) != "\n"),
>> +?????????? identical(textConnectionValue(out)[2L], "LaTeX"));
>> close(out)
>>> ## empty output in R <= 4.2.x
> 
> Yes, known for a few days on the R-core list. I am in the middle of an 
> OS upgrade on that machine and won't have time to do more than report 
> until that (and all the re-building and re-checking) is complete.
> 
>>> ## as.POSIXlt(<very large Date>)? gave integer overflow
>>> stopifnot(as.POSIXlt(.Date(2^31 + 10))$year == 5879680L)
>> Error: as.POSIXlt(.Date(2^31 + 10))$year == 5879680L is not TRUE
>> Execution halted
>>
>>
>> I should have reported this earlier, but somehow did not find the time
>> to do so.? So I thought I mention it here. :)
>>
>> Cheers,
>>
>> ????Berwin
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford



[Rd] A potential POSIXlt->Date bug introduced in r-devel
Prof Brian Ripley