From frederik at ofb.net  Tue Dec  6 17:30:36 2016
From: frederik at ofb.net (frederik at ofb.net)
Date: Tue, 6 Dec 2016 08:30:36 -0800
Subject: [Rd] segfault with POSIXlt zone=NULL zone=""
In-Reply-To: <CAPPM_gRX8zWeDk=jiL2=goqFhbcw12OCW0NXDbnCB9Er6hTdVA@mail.gmail.com>
References: <20161206123720.GA21285@ofb.net>
	<CAPPM_gRX8zWeDk=jiL2=goqFhbcw12OCW0NXDbnCB9Er6hTdVA@mail.gmail.com>
Message-ID: <20161206163036.GB8476@ofb.net>

Hi Joshua,

Thank you for minimizing my test case.

> > Hope I'm not doing something illegal...
> >
> You are.  You're changing the internal structure of a POSIXlt object
> by re-ordering the list elements.  You should not expect a malformed
> POSIXlt object to behave as if it's correctly formed.  You can see
> it's malformed by comparing it's unclass()'d output.
> 
> d <- as.POSIXlt(Sys.time())
> unclass(d)  # valid POSIXlt object
> d$zone <- NULL
> d$zone <- ""
> unclass(d)  # your malformed POSIXlt object

I don't know if these questions are not already obvious, but:

1. Is there a reasonable way to fail more elegantly when a user makes
this mistake?

2. Should we update the documentation for POSIXlt to warn people that
the optional "zone" list element must precede the optional "gmtoff"
list element, in cases where both are present?

Thanks,

Frederick



[Rd] segfault with POSIXlt zone=NULL zone=""
frederik at ofb.net