From maechler at stat.math.ethz.ch  Mon Aug 18 18:35:34 2003
From: maechler at stat.math.ethz.ch (maechler@stat.math.ethz.ch)
Date: Mon Aug 18 17:35:10 2003
Subject: [Rd] round.POSIXt sometimes crashes R (PR#3763)
Message-ID: <200308181535.h7IFZYJH015178@pubhealth.ku.dk>

Grazie mille, Andrea,
for the bug report!

>>>>> "AndreaC" == andrea capodicasa <andrea.capodicasa@albacom.it>
>>>>>     on Mon, 18 Aug 2003 16:21:45 +0200 (MET DST) writes:

    AndreaC> Full_Name: andrea capodicasa Version: 1.7.0 OS: w2k
    AndreaC> sp3 Submission from: (NULL) (212.17.194.154)


    AndreaC> Hi all, the problem is when you try to round.Posix
    AndreaC> an empty vector of dates
  
I can confirm the problem on Linux, using a much newer version
of R (R-devel of today).

A bit shorter version:

> round(ISOdate(2001,1,1)[0], "day")

Process R gleitkomma-Ausnahme at Mon Aug 18 17:23:44 2003
	  ^^^^^^^^^^^^^^^^^^^
( = locale-translation of  "floating point exception" )

--------------
The same for Linux and Solaris:
Using  "R -d gdb" and "bt" (= backtrace) after the error reveals

(gdb) bt
#0  0xfefbee9c in .rem () from /usr/lib/libc.so.1
#1  0x0004e4b4 in do_formatPOSIXlt (call=0xebc9c8, op=0xebc9c8, args=0xed2fb8, 
    env=0x1) at ../../../R/src/main/datetime.c:565
......
.......

-----------------

There's an obvious way to fix this bug on the R- (as opposed to C-)
level, and I'd probably just do it.
However, I wonder if the logic in the above C code is okay..

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><


[Rd] round.POSIXt sometimes crashes R (PR#3763)
maechler@stat.math.ethz.ch