{"action":"created","issue":{"url":"https://api.github.com/repos/arduino/Arduino/issues/7181","repository_url":"https://api.github.com/repos/arduino/Arduino","labels_url":"https://api.github.com/repos/arduino/Arduino/issues/7181/labels{/name}","comments_url":"https://api.github.com/repos/arduino/Arduino/issues/7181/comments","events_url":"https://api.github.com/repos/arduino/Arduino/issues/7181/events","html_url":"https://github.com/arduino/Arduino/issues/7181","id":293846394,"number":7181,"title":"delayMicroseconds() is broken in AVR core versions that do LTO...","user":{"login":"WestfW","id":425027,"avatar_url":"https://avatars0.githubusercontent.com/u/425027?v=4","gravatar_id":"","url":"https://api.github.com/users/WestfW","html_url":"https://github.com/WestfW","followers_url":"https://api.github.com/users/WestfW/followers","following_url":"https://api.github.com/users/WestfW/following{/other_user}","gists_url":"https://api.github.com/users/WestfW/gists{/gist_id}","starred_url":"https://api.github.com/users/WestfW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WestfW/subscriptions","organizations_url":"https://api.github.com/users/WestfW/orgs","repos_url":"https://api.github.com/users/WestfW/repos","events_url":"https://api.github.com/users/WestfW/events{/privacy}","received_events_url":"https://api.github.com/users/WestfW/received_events","type":"User","site_admin":false},"labels":[{"id":197265361,"url":"https://api.github.com/repos/arduino/Arduino/labels/Architecture:%20AVR","name":"Architecture: AVR","color":"fbca04","default":false},{"id":20979470,"url":"https://api.github.com/repos/arduino/Arduino/labels/Component:%20Core","name":"Component: Core","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-02-02T10:46:09Z","updated_at":"2018-02-06T08:08:48Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Recent versions of the Arduino IDE/Core for AVR do Link Time Optimization, which means that calls to delayMicroseconds() where the argument is constant are likely to be optimized to the point where they become significantly inaccurate for small numbers...\r\n\r\nThe simplest solution is probably to define delayMicroseconds() with a \"never inline\" attribute, but it would probably be a better idea to use libc and/or compiler built-ins instead.\r\n\r\ntest sketch:\r\n```\r\nvoid setup() {\r\n}\r\n\r\nvoid loop() {\r\n  byte x;\r\n  x = PORTB;\r\n  delayMicroseconds(1);\r\n  x = PORTB;\r\n  delayMicroseconds(2);\r\n  x = PORTB;\r\n  delayMicroseconds(3);\r\n  x = PORTB;\r\n  delayMicroseconds(100);\r\n  x = PORTB;\r\n  delayMicroseconds(2334);\r\n  x = PORTB;\r\n  delayMicroseconds(x);\r\n  x = PORTB;\r\n}\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/arduino/Arduino/issues/comments/363342706","html_url":"https://github.com/arduino/Arduino/issues/7181#issuecomment-363342706","issue_url":"https://api.github.com/repos/arduino/Arduino/issues/7181","id":363342706,"user":{"login":"WestfW","id":425027,"avatar_url":"https://avatars0.githubusercontent.com/u/425027?v=4","gravatar_id":"","url":"https://api.github.com/users/WestfW","html_url":"https://github.com/WestfW","followers_url":"https://api.github.com/users/WestfW/followers","following_url":"https://api.github.com/users/WestfW/following{/other_user}","gists_url":"https://api.github.com/users/WestfW/gists{/gist_id}","starred_url":"https://api.github.com/users/WestfW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WestfW/subscriptions","organizations_url":"https://api.github.com/users/WestfW/orgs","repos_url":"https://api.github.com/users/WestfW/repos","events_url":"https://api.github.com/users/WestfW/events{/privacy}","received_events_url":"https://api.github.com/users/WestfW/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T08:08:48Z","updated_at":"2018-02-06T08:08:48Z","author_association":"CONTRIBUTOR","body":"No, the \"noinlne\" still apparently allows calls with constant arguments to get their own \"constprop\" not-inline but still too short functions to be generated.\r\n\r\n`    void __attribute__((noinline)) __attribute__((optimize(\"no-ipa-cp\"))) delayMicroseconds(unsigned int us);`\r\n\r\nworks better, but is becoming pretty obscure and gcc-specific.  Maybe it'd be easier to code the whole mess in assembly language...\r\n"}}
{"actor":{"display_login":"WestfW"}}