joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
325 stars 102 forks source link

UBSAN reports int assigned value of Inf #100

Closed joshuaulrich closed 3 years ago

joshuaulrich commented 3 years ago

UBSAN reports the following in TTR_0.24.0:

Executing test function test.EMA.ratio.eq.0  ... moving_averages.c:38:13: runtime error:
    inf is outside the range of representable values of type 'int'
    #0 0x7f69ec6332b6 in ema /data/gannet/ripley/R/packages/tests-clang-SAN/TTR/src/moving_averages.c:38:13

Reproducible with:

hma <- HMA(ttrc[,"Close"])

This is caused when ratio = 0. Thanks to Prof Ripley for the report.