{"action":"created","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/3730","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/3730/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/3730/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/3730/events","html_url":"https://github.com/kripken/emscripten/issues/3730","id":104303125,"number":3730,"title":"Missing $n arguments for EM_ASM_INT(or DOUBLE) blocks that don't use all of their arguments","user":{"login":"svetlin-mladenov","id":639378,"avatar_url":"https://avatars.githubusercontent.com/u/639378?v=3","gravatar_id":"","url":"https://api.github.com/users/svetlin-mladenov","html_url":"https://github.com/svetlin-mladenov","followers_url":"https://api.github.com/users/svetlin-mladenov/followers","following_url":"https://api.github.com/users/svetlin-mladenov/following{/other_user}","gists_url":"https://api.github.com/users/svetlin-mladenov/gists{/gist_id}","starred_url":"https://api.github.com/users/svetlin-mladenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svetlin-mladenov/subscriptions","organizations_url":"https://api.github.com/users/svetlin-mladenov/orgs","repos_url":"https://api.github.com/users/svetlin-mladenov/repos","events_url":"https://api.github.com/users/svetlin-mladenov/events{/privacy}","received_events_url":"https://api.github.com/users/svetlin-mladenov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T16:19:31Z","updated_at":"2015-09-01T22:41:49Z","closed_at":null,"body":"If an EM_ASM_INT block gets more then 1 argument and some of the arguments are not used then the compiler doesn't generate $1, $2 or so on arguments for the the ASM_CONST function.\r\n\r\nHere is a test case that will hopefully clarify what I mean:\r\n\r\n    def test_unused_em_asm_arguments(self):\r\n      src = r'''\r\n        #include <stdio.h>\r\n        #include <emscripten.h>\r\n  \r\n        int main(int argc, char **argv) {\r\n          int sum = EM_ASM_INT({\r\n             return $0 + $2;\r\n          }, 0, 1, 2);\r\n          printf(\"0+2=%d\\n\", sum);\r\n          return 0;\r\n        }\r\n      '''\r\n      self.do_run(src, '''0+2=2''')\r\n\r\nAnd here is the generated ASM_CONSTS:\r\n\r\n    var ASM_CONSTS = [function($0) { { return $0 + $2; } }];\r\n\r\nAs you can see the $1 and $2 are missing. I am using the incoming branch commit 108797d366f4e0ee8fab.\r\n\r\nif $1 is added to the body of the EM_ASM_INT block then everything works es expected. For example:\r\n\r\n        int main(int argc, char **argv) {\r\n          int sum = EM_ASM_INT({\r\n             $1;\r\n             return $0 + $2;\r\n          }, 0, 1, 2);\r\n          printf(\"0+2=%d\\n\", sum);\r\n          return 0;\r\n        }\r\n\r\ngenerates:\r\n\r\n   var ASM_CONSTS = [function($0, $1, $2) { { $1; return $0 + $2; } }];"},"comment":{"url":"https://api.github.com/repos/kripken/emscripten/issues/comments/136883565","html_url":"https://github.com/kripken/emscripten/issues/3730#issuecomment-136883565","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/3730","id":136883565,"user":{"login":"kripken","id":173661,"avatar_url":"https://avatars.githubusercontent.com/u/173661?v=3","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T22:41:48Z","updated_at":"2015-09-01T22:41:48Z","body":"Thanks for reporting, and especially for reporting with a testcase in the test suite format!\r\n\r\nThis was an embarrassing bug with the compiler assuming all arguments were used. Fixed on incoming (note: need to update both fastcomp and emscripten repos)."}}