From maechler at stat.math.ethz.ch  Fri Jun 25 09:19:40 2004
From: maechler at stat.math.ethz.ch (maechler@stat.math.ethz.ch)
Date: Fri Jun 25 09:19:44 2004
Subject: [Rd] Bug in parse(text = <long polynom>) (PR#7022)
Message-ID: <20040625071940.9096610871@slim.kubism.ku.dk>

Merci beaucoup, Jean,
for the bug report -- which I'm no "completeing" to R-bugs

>>>>> "Jean" == Jean Coursol <coursol@cristal.math.u-psud.fr>
>>>>>     on Thu, 24 Jun 2004 15:22:37 +0200 (CEST) writes:

    Jean> I was exploring the polynom library with students:

 <and found a segmentation fault from parsing a long expression>

The following is reproducible also with the current version of R
1.9.1 [on RHEL Linux]

horner <- function(p) {
        a <- as.character(rev(unclass(p)))
        h <- a[1]
        while (length(a <- a[-1]) > 0) {
            h <- paste("x*(", h, ")", sep = "")
            if (a[1] != 0)
                h <- paste(a[1], " + ", h, sep = "")
        }
        h
}

library(polynom)

x <- polynomial()
z <- (1+x)^100
zh <- horner(z)

nchar(zh)
## [1] 2404

parse(text = zh) # => Segmentation fault

## where Jean wrote  '(it ran one time !!!)'
## and it happens the first time for me.


[Rd] Bug in parse(text = <long polynom>) (PR#7022)
maechler@stat.math.ethz.ch