{"action":"created","issue":{"url":"https://api.github.com/repos/zeux/pugixml/issues/125","repository_url":"https://api.github.com/repos/zeux/pugixml","labels_url":"https://api.github.com/repos/zeux/pugixml/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/zeux/pugixml/issues/125/comments","events_url":"https://api.github.com/repos/zeux/pugixml/issues/125/events","html_url":"https://github.com/zeux/pugixml/issues/125","id":192044068,"number":125,"title":"Overflow in src/pugixml.cpp:4524","user":{"login":"jbakosi","id":13008285,"avatar_url":"https://avatars.githubusercontent.com/u/13008285?v=3","gravatar_id":"","url":"https://api.github.com/users/jbakosi","html_url":"https://github.com/jbakosi","followers_url":"https://api.github.com/users/jbakosi/followers","following_url":"https://api.github.com/users/jbakosi/following{/other_user}","gists_url":"https://api.github.com/users/jbakosi/gists{/gist_id}","starred_url":"https://api.github.com/users/jbakosi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbakosi/subscriptions","organizations_url":"https://api.github.com/users/jbakosi/orgs","repos_url":"https://api.github.com/users/jbakosi/repos","events_url":"https://api.github.com/users/jbakosi/events{/privacy}","received_events_url":"https://api.github.com/users/jbakosi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-11-28T16:01:27Z","updated_at":"2016-11-29T18:45:48Z","closed_at":null,"body":"I'm trying to build using the Cray compiler, which refuses to build producing the following error:\r\n```\r\nCC-3059 crayc++: INTERNAL __C_FILE_SCOPE_DATA__, File = <pugixml>/src/pugixml.cpp, Line = 4524, Column = 4 \r\n  Expected no overflow in routine.\r\n```\r\n\r\nThe line in questions is in ```template <typename U> U string_to_integer(const char_t* value, U minneg, U maxpos)```:\r\n```\r\nreturn (overflow || result > minneg) ? 0 - minneg : 0 - result;\r\n```\r\nattempting to subtract a positive integer from zero. Not sure why gnu/clang/intel compilers do not complain, but the Cray compiler appears to do rightly so. Is there an easy fix?"},"comment":{"url":"https://api.github.com/repos/zeux/pugixml/issues/comments/263660313","html_url":"https://github.com/zeux/pugixml/issues/125#issuecomment-263660313","issue_url":"https://api.github.com/repos/zeux/pugixml/issues/125","id":263660313,"user":{"login":"zeux","id":1106629,"avatar_url":"https://avatars.githubusercontent.com/u/1106629?v=3","gravatar_id":"","url":"https://api.github.com/users/zeux","html_url":"https://github.com/zeux","followers_url":"https://api.github.com/users/zeux/followers","following_url":"https://api.github.com/users/zeux/following{/other_user}","gists_url":"https://api.github.com/users/zeux/gists{/gist_id}","starred_url":"https://api.github.com/users/zeux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeux/subscriptions","organizations_url":"https://api.github.com/users/zeux/orgs","repos_url":"https://api.github.com/users/zeux/repos","events_url":"https://api.github.com/users/zeux/events{/privacy}","received_events_url":"https://api.github.com/users/zeux/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T18:45:48Z","updated_at":"2016-11-29T18:45:48Z","body":"I guess one option is to switch to two-complement version for Cray to avoid this, something like:\r\n\r\n    #ifdef _CRAYC\r\n        return (overflow || result > minneg) ? ~minneg + 1 : ~result + 1;\r\n    #else\r\n        return (overflow || result > minneg) ? 0 - minneg : 0 - result;\r\n    #endif\r\n\r\nI'm somewhat surprised that the same error does not happen for things like this though:\r\n\r\n    return string_to_integer<unsigned int>(value, 0 - static_cast<unsigned int>(INT_MIN), INT_MAX);\r\n\r\n"}}
{"actor":{"display_login":"zeux"}}