{"action":"created","issue":{"url":"https://api.github.com/repos/lballabio/QuantLib/issues/534","repository_url":"https://api.github.com/repos/lballabio/QuantLib","labels_url":"https://api.github.com/repos/lballabio/QuantLib/issues/534/labels{/name}","comments_url":"https://api.github.com/repos/lballabio/QuantLib/issues/534/comments","events_url":"https://api.github.com/repos/lballabio/QuantLib/issues/534/events","html_url":"https://github.com/lballabio/QuantLib/issues/534","id":357635979,"node_id":"MDU6SXNzdWUzNTc2MzU5Nzk=","number":534,"title":"Serious crash-causing bug in Actual365Fixed::CA_Impl::yearFraction","user":{"login":"irigopou","id":17901453,"node_id":"MDQ6VXNlcjE3OTAxNDUz","avatar_url":"https://avatars0.githubusercontent.com/u/17901453?v=4","gravatar_id":"","url":"https://api.github.com/users/irigopou","html_url":"https://github.com/irigopou","followers_url":"https://api.github.com/users/irigopou/followers","following_url":"https://api.github.com/users/irigopou/following{/other_user}","gists_url":"https://api.github.com/users/irigopou/gists{/gist_id}","starred_url":"https://api.github.com/users/irigopou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irigopou/subscriptions","organizations_url":"https://api.github.com/users/irigopou/orgs","repos_url":"https://api.github.com/users/irigopou/repos","events_url":"https://api.github.com/users/irigopou/events{/privacy}","received_events_url":"https://api.github.com/users/irigopou/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-06T12:39:19Z","updated_at":"2018-09-17T14:40:38Z","closed_at":"2018-09-11T08:51:38Z","author_association":"NONE","body":"The implementation of Actual365Fixed::CA_Impl::yearFraction(...) in \\ql\\time\\daycounters\\actual365fixed.cpp contains the following code:\r\n\r\n        Time dcs = daysBetween(d1,d2);\r\n        Time dcc = daysBetween(refPeriodStart,refPeriodEnd);\r\n        Integer months = Integer(0.5+12*dcc/365);\r\n        Integer frequency = Integer( 12/months);\r\n\r\n        if ( dcs < 365/frequency)\r\n            return dcs/365.0;\r\n\r\n        return 1./frequency - (dcc-dcs)/365.0;\r\n\r\nIn situations where refPeriodStart == refPeriodEnd, dcc evaluates to 0, which sets frequency to 0, which causes the line `Integer frequency = Integer( 12/months);` to throw a fatal exception that cannot be handled!\r\nEven the next line `if ( dcs < 365/frequency)` is at risk when frequency == 0.\r\n\r\nSince dcc is often 0 when also dcs is 0, the code may be edited so that 0 is returned immediately if dcs == 0, before the `if ( dcs < 365/frequency)` gets evaluated."},"comment":{"url":"https://api.github.com/repos/lballabio/QuantLib/issues/comments/422044188","html_url":"https://github.com/lballabio/QuantLib/issues/534#issuecomment-422044188","issue_url":"https://api.github.com/repos/lballabio/QuantLib/issues/534","id":422044188,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjA0NDE4OA==","user":{"login":"lballabio","id":170560,"node_id":"MDQ6VXNlcjE3MDU2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/170560?v=4","gravatar_id":"","url":"https://api.github.com/users/lballabio","html_url":"https://github.com/lballabio","followers_url":"https://api.github.com/users/lballabio/followers","following_url":"https://api.github.com/users/lballabio/following{/other_user}","gists_url":"https://api.github.com/users/lballabio/gists{/gist_id}","starred_url":"https://api.github.com/users/lballabio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lballabio/subscriptions","organizations_url":"https://api.github.com/users/lballabio/orgs","repos_url":"https://api.github.com/users/lballabio/repos","events_url":"https://api.github.com/users/lballabio/events{/privacy}","received_events_url":"https://api.github.com/users/lballabio/received_events","type":"User","site_admin":false},"created_at":"2018-09-17T14:40:38Z","updated_at":"2018-09-17T14:40:38Z","author_association":"OWNER","body":"True.  refPeriodStart == refPeriodEnd doesn't make a lot of sense to me, though.  Do you have an actual use case?"}}
{"actor":{"display_login":"lballabio"}}