{"action":"created","issue":{"url":"https://api.github.com/repos/boostorg/spirit/issues/400","repository_url":"https://api.github.com/repos/boostorg/spirit","labels_url":"https://api.github.com/repos/boostorg/spirit/issues/400/labels{/name}","comments_url":"https://api.github.com/repos/boostorg/spirit/issues/400/comments","events_url":"https://api.github.com/repos/boostorg/spirit/issues/400/events","html_url":"https://github.com/boostorg/spirit/issues/400","id":363976037,"node_id":"MDU6SXNzdWUzNjM5NzYwMzc=","number":400,"title":"`qi_repo_keywords` test fails due to msvc-14.1 codegen bug","user":{"login":"Kojoley","id":2743474,"node_id":"MDQ6VXNlcjI3NDM0NzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2743474?v=4","gravatar_id":"","url":"https://api.github.com/users/Kojoley","html_url":"https://github.com/Kojoley","followers_url":"https://api.github.com/users/Kojoley/followers","following_url":"https://api.github.com/users/Kojoley/following{/other_user}","gists_url":"https://api.github.com/users/Kojoley/gists{/gist_id}","starred_url":"https://api.github.com/users/Kojoley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kojoley/subscriptions","organizations_url":"https://api.github.com/users/Kojoley/orgs","repos_url":"https://api.github.com/users/Kojoley/repos","events_url":"https://api.github.com/users/Kojoley/events{/privacy}","received_events_url":"https://api.github.com/users/Kojoley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-26T11:12:13Z","updated_at":"2018-10-13T19:35:05Z","closed_at":null,"author_association":"COLLABORATOR","body":"`qi_repo_keywords` test fails because of codegen bug introduced in the latest Visual Studio versions. I did find the exact version where it started to fail, but it looks like the last good version should be 15.8.2.\r\n\r\nThe issue was reported to Microsoft. <sup>[\\[link\\]](https://developercommunity.visualstudio.com/content/problem/342397/x64-optimization-codgen-bug-in-latest-compiler-ver.html)</sup>\r\n\r\n<details>\r\n  <summary>b2 output</summary>\r\n\r\n```\r\ntesting.capture-output bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.run\r\n====== BEGIN OUTPUT ======\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(86): test 'test(\"a=a c=1\", kwd(\"a\")[ '=' > char_] / kwd(\"b\")[ '=' > char_] / kwd(\"c\")['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(91): test 'test(\"a=a b=b c=1\", kwd(\"a\",1)[ '=' > char_] / kwd(\"b\")[ '=' > char_] / kwd(\"c\")['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(92): test 'test(\"a=a b=c b=e c=1\", kwd(\"a\",1)[ '=' > char_] / kwd(\"b\",2)[ '=' > char_] / kwd(\"c\")['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(96): test 'test(\"a=f b=c b=e c=1\", kwd(\"a\",1,2)[ '=' > char_] / kwd(\"b\",0,2)[ '=' > char_] / kwd(\"c\",1,2)['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(98): test 'test(\"a=g a=f b=c b=e c=1\", kwd(\"a\",1,2)[ '=' > char_] / kwd(\"b\",0,2)[ '=' > char_] / kwd(\"c\",1,2)['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(102): test 'test(\"a=f b=c b=e c=1\", kwd(\"a\",1,inf)[ '=' > char_] / kwd(\"b\",0,inf)[ '=' > char_] / kwd(\"c\",1,inf)['=' > int_], space )' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(104): test 'test(\"a=f a=f a=g b=c b=e c=1 a=e\", kwd(\"a\",1,inf)[ '=' > char_] / kwd(\"b\",0,inf)[ '=' > char_] / kwd(\"c\",1,inf)['=' > int_], space )' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(134): test 'test(\"B=a c=1 a=E\", no_case[kwd(\"a\")[ \"=E\" ] / kwd(\"b\")[ '=' > char_] / kwd(\"c\")['=' > int_]], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(135): test 'test(\"B=a c=1 a=e\", no_case[kwd(\"a\")[ \"=E\" ] / kwd(\"b\")[ '=' > char_] / kwd(\"c\")['=' > int_]], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(137): test 'test(\"b=a c=1 A=E\", no_case[kwd(\"a\")[ '=' > char_]] / kwd(\"b\")[ '=' > char_] / kwd(\"c\")['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\nlibs\\spirit\\repository\\test\\qi\\keywords.cpp(139): test 'test(\"A=a c=1 a=E\", ikwd(\"a\")[ '=' > char_] / kwd(\"b\")[ '=' > char_] / kwd(\"c\")['=' > int_], space)' failed in function 'int __cdecl main(void)'\r\n \r\nEXIT STATUS: 3 \r\n====== END OUTPUT ======\r\n    \r\n    set status=0\r\n    if %status% NEQ 0 (\r\n        echo Skipping test execution due to testing.execute=off\r\n        exit 0\r\n    )\r\n     \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.exe\"   > \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.output\" 2>&1 \r\n    set status=%ERRORLEVEL%\r\n    echo. >> \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.output\"\r\n    echo EXIT STATUS: %status% >> \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.output\"\r\n    if %status% EQU 0 (\r\n        copy \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.output\" \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.run\"\r\n    )\r\n    set verbose=0\r\n    if %status% NEQ 0 (\r\n        set verbose=1\r\n    )\r\n    if %verbose% EQU 1 (\r\n        echo ====== BEGIN OUTPUT ======\r\n        type \"bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.output\"\r\n        echo ====== END OUTPUT ======\r\n    )\r\n    exit %status%\r\n...failed testing.capture-output bin.v2\\libs\\spirit\\repository\\test\\qi_repo_keywords.test\\msvc-14.1\\release\\address-model-64\\threading-multi\\qi_repo_keywords.run...\r\n```\r\n\r\n</details>\r\n\r\nDebug\r\n---\r\n\r\nI have succeeded to identify a place where the problem happens, if you mark `boost::spirit::qi::sequence_base::parse_impl` as noinline and place the breakpoint on `first = iter;` line, you will see this:\r\n\r\n```\r\n+\tfirst\t0x000000013f9e13c5 \"=1\"\tconst char * &\r\n+\titer\t0x000000013f9e13c7 \"\"\tconst char *\r\n```\r\nand after stepping over the line:\r\n```\r\n+\tfirst\t0x000000013f9e13c6 \"1\"\tconst char * &\r\n+\titer\t0x000000013f9e13c7 \"\"\tconst char *\r\n```\r\n\r\nOf course it is wrong. `first` cannot differ from `iter` after `first = iter` assignment.\r\n\r\nAt disassembly it looks like the optimizer throws away one of two iterator increments.\r\n\r\nSolutions\r\n---\r\n\r\nThe only found workarounds are:\r\n  - Remove inline keyword from `spirit::any_if` function.\r\n  - Move `first = iter` into the dedicated noinline function.\r\n  - Copy the iterator before assignment `first = make_copy(iter)`\r\n    with a helper noinline function.\r\n\r\nI do not see any of them as acceptable.\r\n"},"comment":{"url":"https://api.github.com/repos/boostorg/spirit/issues/comments/429569279","html_url":"https://github.com/boostorg/spirit/issues/400#issuecomment-429569279","issue_url":"https://api.github.com/repos/boostorg/spirit/issues/400","id":429569279,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTU2OTI3OQ==","user":{"login":"Kojoley","id":2743474,"node_id":"MDQ6VXNlcjI3NDM0NzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2743474?v=4","gravatar_id":"","url":"https://api.github.com/users/Kojoley","html_url":"https://github.com/Kojoley","followers_url":"https://api.github.com/users/Kojoley/followers","following_url":"https://api.github.com/users/Kojoley/following{/other_user}","gists_url":"https://api.github.com/users/Kojoley/gists{/gist_id}","starred_url":"https://api.github.com/users/Kojoley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kojoley/subscriptions","organizations_url":"https://api.github.com/users/Kojoley/orgs","repos_url":"https://api.github.com/users/Kojoley/repos","events_url":"https://api.github.com/users/Kojoley/events{/privacy}","received_events_url":"https://api.github.com/users/Kojoley/received_events","type":"User","site_admin":false},"created_at":"2018-10-13T19:35:05Z","updated_at":"2018-10-13T19:35:05Z","author_association":"COLLABORATOR","body":"The regression in MSVC was confirmed and fixed. It is still unclear when it was introduced and which release will have the fix. I am leaving the issue opened to remind myself to revert #402 when updated msvc land on appveyor."}}
{"actor":{"display_login":"Kojoley"}}