[Rd] [PATCH] fix CHECK_this_length in sprintf.c

Martin Maechler maechler at stat.math.ethz.ch
Thu Apr 7 12:46:54 CEST 2016


>>>>> Matthew Fowles Kulukundis <matt.fowles at gmail.com>
>>>>>     on Tue, 5 Apr 2016 11:17:30 -0400 writes:

    > All~
    > CHECK_this_length macro expands to multiple statements making it unsafe to
    > use in a single line `if` statement (as is happening near line 335).  This
    > fixes the macro using the standard `do { } while (0)` macro trick.

yes, but you forgot the closing '}' ... so you could not even
have compiled R after applying your patch.  

Also, it would be nice to contrive a minimal example where the
change makes a difference.  This  "fails" to trigger :

--------------------------------
as.double.foo <- function(x) x[FALSE]
x <- structure(3, class="foo")
as.numeric(x) # numeric(0)

sprintf("%d !", x)# "3 !"  instead of giving an error
--------------------------------

Thank you, Matt, in any case; this (with the "{" !) has now gone
into the source.

Martin

    > Matt
    > x[DELETED ATTACHMENT external: r-sprintf.patch, text/x-patch]
    > ______________________________________________
    > R-devel at r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list