Hungry Mind , Blog about everything in IT - C#, Java, C++, .NET, Windows, WinAPI, ...

__await is still broken in Visual Studio 2015 RTM

Connect issue

The following simple code does not work:

#include "stdafx.h"
#include <experimental\generator>
#include <future>

using namespace std;
using namespace std::experimental;

future<int> get_int()
    return async([] { return 0; });

future<int> wait_int()
    return __await get_int();

int main()
    auto const i = wait_int().get();
    return 0;

App hits int 3 instruction (XXX.exe has triggered a breakpoint) and then hangs forever waiting for suspended coroutine to finish. Bravo! My investigation shows that compiler generates invalid instructions within XXX.exe!wait_int$_ResumeCoro$2() function:

00007FF6166FB0F0  mov         qword ptr [rsp+8],rcx  
00007FF6166FB0F5  push        rbp  
00007FF6166FB0F6  sub         rsp,30h  
00007FF6166FB0FA  mov         qword ptr [rsp+20h],0FFFFFFFFFFFFFFFEh  
00007FF6166FB103  mov         rbp,qword ptr [$S2]  
00007FF6166FB108  mov         eax,dword ptr [rbp+20h]  
00007FF6166FB10B  mov         dword ptr [rbp+78h],eax  
00007FF6166FB10E  cmp         dword ptr [rbp+78h],5  

rbp has the address of coroutine frame, frame has two consequent 64-bit values - address of resume method and some internal state flag, which is set to 2 initially. dword ptr [rbp+20h] - this instruction obtains the flag, but the offset is completely wrong, it must be dword ptr [rbp+8h]. So all cases of state flag switch are bypassed. Default case makes the assert hit. Boom.

UPD: It doesn't support Debug Information Format == Program Database for Edit And Continue (/Zl). With this setting set to something else the code is generated properly: mov eax, [rbp+8].

7 коммент.:

Hammed комментирует...

This content creates a new hope and inspiration with in me. Thanks for sharing article like this. The way you have stated everything above is quite awesome. Keep blogging like this
SEO Company in Chennai

Unknown комментирует...

Thanks admin for sharing the unique content, you have done a great job

Installment loans in Mississippi
Payday loans in Mississippi
Title loans in Mississippi

Unknown комментирует...

Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

Installment loans in alabama
Payday loans in alabama
Title loans in alabama
Cash Advances in alabama

Unknown комментирует...

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic.

Pawn Shop

Pawn Loans

Pawn Shops

Pawn Loan

Pawn Shop near me

Unknown комментирует...

Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....

Carwash in omr
usedcars in omr
automotors in omr
car accessories in omr
secondhand car in omr

Antony Jack комментирует...

A nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
ERP Software Companies
Best ERP Software
ERP Software In India
ERP Companies In Chennai
ERP Software In Chennai

Fivotech LLP | Digital Marketing Agency комментирует...

If you own a website SEO is the best way to grow your business in this modern era. We are a Digital marketing agency providing SEO Services in Chennai. Hiring an SEO expert will increase your chances of growing your business better and faster than your competitor. So, if you are looking for Best SEO Services in Chennai feel free to contact us.

Отправка комментария

Copyright 2007-2011 Chabster