{"action":"created","issue":{"url":"https://api.github.com/repos/boostorg/geometry/issues/315","labels_url":"https://api.github.com/repos/boostorg/geometry/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/boostorg/geometry/issues/315/comments","events_url":"https://api.github.com/repos/boostorg/geometry/issues/315/events","html_url":"https://github.com/boostorg/geometry/pull/315","id":93995673,"number":315,"title":"Fix: possible infinite loop in has_spikes","user":{"login":"mkaravel","id":6397014,"avatar_url":"https://avatars.githubusercontent.com/u/6397014?v=3","gravatar_id":"","url":"https://api.github.com/users/mkaravel","html_url":"https://github.com/mkaravel","followers_url":"https://api.github.com/users/mkaravel/followers","following_url":"https://api.github.com/users/mkaravel/following{/other_user}","gists_url":"https://api.github.com/users/mkaravel/gists{/gist_id}","starred_url":"https://api.github.com/users/mkaravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkaravel/subscriptions","organizations_url":"https://api.github.com/users/mkaravel/orgs","repos_url":"https://api.github.com/users/mkaravel/repos","events_url":"https://api.github.com/users/mkaravel/events{/privacy}","received_events_url":"https://api.github.com/users/mkaravel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-09T09:01:33Z","updated_at":"2015-07-09T23:08:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/boostorg/geometry/pulls/315","html_url":"https://github.com/boostorg/geometry/pull/315","diff_url":"https://github.com/boostorg/geometry/pull/315.diff","patch_url":"https://github.com/boostorg/geometry/pull/315.patch"},"body":"If the range passed to `has_spikes` consists of points with `NaN` coordinates (this can happen if the range passed as been computed as the result, e.g., of a set operation), then `has_spikes` can enter an infinite loop.\r\n\r\nIf a point `p` has such `NaN` coordinates, then `p` is considered as not equal to itself, a property/feature assumed in the previous implementation of `has_spikes`), and the following calls (in the older version of `has_spikes`) to `std::find_if` never return:\r\n```\r\nstd::find_if(prev, boost::end(view), not_equal(*prev));\r\n```\r\nand\r\n```\r\nstd::find_if(cur, boost::end(view), not_equal(*cur));\r\n```\r\n\r\nThe solution if to essentially call `std::find_if` as `std::find_if(second, first, last, not_equal(*first))`, which avoids the implicit assumption that the `bg::equals(*first, *first)` returns `true`.\r\n\r\n***Note:*** the problem appears for geometries with `NaN` coordinates. The point addressed here is to have `has_spikes` return instead of entering an endless loop; the result returned, however, does not (and could not) have any geometric significance."},"comment":{"url":"https://api.github.com/repos/boostorg/geometry/issues/comments/120171261","html_url":"https://github.com/boostorg/geometry/pull/315#issuecomment-120171261","issue_url":"https://api.github.com/repos/boostorg/geometry/issues/315","id":120171261,"user":{"login":"mkaravel","id":6397014,"avatar_url":"https://avatars.githubusercontent.com/u/6397014?v=3","gravatar_id":"","url":"https://api.github.com/users/mkaravel","html_url":"https://github.com/mkaravel","followers_url":"https://api.github.com/users/mkaravel/followers","following_url":"https://api.github.com/users/mkaravel/following{/other_user}","gists_url":"https://api.github.com/users/mkaravel/gists{/gist_id}","starred_url":"https://api.github.com/users/mkaravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkaravel/subscriptions","organizations_url":"https://api.github.com/users/mkaravel/orgs","repos_url":"https://api.github.com/users/mkaravel/repos","events_url":"https://api.github.com/users/mkaravel/events{/privacy}","received_events_url":"https://api.github.com/users/mkaravel/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T23:08:32Z","updated_at":"2015-07-09T23:08:32Z","body":"I had in mind to add a unit test. Will do before merging (of course I am also waiting for Adam's approval)."}}