cl goin crazy??



  • @SeppJ Da sitzen wir zur Abwechslung mal im selben Boot ^^
    (Aber mein Hass auf cl steigt merklich)

    Ohne dem bitset

    #include <cstddef>
    #include <bitset>
    #include <iostream>
    
    int main()
    {
    	std::size_t constexpr digits{ 32 };
    
    	for (std::size_t i = 0; i < digits; ++i) {
    		std::cout << i << '\t' /* << std::bitset<digits>{ 1ull << i } */ << '\n';
    		std::cout.flush();  // desperation
    	}
    	std::cout.put('\n');
    }
    

    zählt wenigstens i richtig.



  • @Others: Hilfts eher wenn ich ASM von release-builds bringe ohne debug-gedöhns?

    release win32:

    #include <cstddef>
    #include <bitset>
    #include <iostream>
    
    int main()
    {
    00601220  push        ebp  
    00601221  mov         ebp,esp  
    00601223  and         esp,0FFFFFFF8h  
    00601226  sub         esp,8  
    00601229  push        esi  
    0060122A  push        edi  
    	std::size_t constexpr digits{ 32 };
    
    	for (std::size_t i = 0; i < digits; ++i) {
    0060122B  xor         esi,esi  
    0060122D  nop         dword ptr [eax]  
    		std::cout << i << '\t' << std::bitset<digits>{ 1ull << i } << '\n';
    00601230  mov         ecx,dword ptr [__imp_std::cout (0603070h)]  
    00601236  push        esi  
    00601237  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0603034h)]  
    0060123D  mov         dl,9  
    0060123F  mov         ecx,eax  
    00601241  call        std::operator<<<std::char_traits<char> > (06013B0h)  
    00601246  mov         edx,esi  
    00601248  xor         edi,edi  
    0060124A  bts         edi,edx  
    0060124D  xor         ecx,ecx  
    0060124F  cmp         edx,20h  
    00601252  lea         edx,[esp+0Ch]  
    00601256  cmovae      ecx,edi  
    00601259  xor         edi,ecx  
    0060125B  mov         ecx,eax  
    0060125D  mov         dword ptr [esp+0Ch],edi  
    00601261  call        std::operator<<<char,std::char_traits<char>,32> (06015C0h)  
    00601266  mov         dl,0Ah  
    00601268  mov         ecx,eax  
    0060126A  call        std::operator<<<std::char_traits<char> > (06013B0h)  
    		std::cout.flush();  // desperation
    0060126F  mov         ecx,dword ptr [__imp_std::cout (0603070h)]  
    00601275  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::flush (060303Ch)]  
    0060127B  inc         esi  
    0060127C  cmp         esi,20h  
    0060127F  jb          main+10h (0601230h)  
    	}
    	std::cout.put('\n');
    00601281  mov         ecx,dword ptr [__imp_std::cout (0603070h)]  
    00601287  push        0Ah  
    00601289  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::put (0603038h)]  
    }
    0060128F  pop         edi  
    00601290  xor         eax,eax  
    00601292  pop         esi  
    00601293  mov         esp,ebp  
    00601295  pop         ebp  
    00601296  ret  
    

    release x64:

    #include <cstddef>
    #include <bitset>
    #include <iostream>
    
    int main()
    {
    00007FF7B8C11290  mov         qword ptr [rsp+10h],rbx  
    00007FF7B8C11295  push        rdi  
    00007FF7B8C11296  sub         rsp,20h  
    	std::size_t constexpr digits{ 32 };
    
    	for (std::size_t i = 0; i < digits; ++i) {
    00007FF7B8C1129A  xor         edi,edi  
    00007FF7B8C1129C  lea         ebx,[rdi+1]  
    00007FF7B8C1129F  nop  
    		std::cout << i << '\t' << std::bitset<digits>{ 1ull << i } << '\n';
    00007FF7B8C112A0  mov         rcx,qword ptr [__imp_std::cout (07FF7B8C130B8h)]  
    00007FF7B8C112A7  mov         rdx,rdi  
    00007FF7B8C112AA  call        qword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (07FF7B8C130F8h)]  
    00007FF7B8C112B0  mov         rcx,rax  
    00007FF7B8C112B3  mov         dl,9  
    00007FF7B8C112B5  call        std::operator<<<std::char_traits<char> > (07FF7B8C113E0h)  
    00007FF7B8C112BA  lea         rdx,[rsp+30h]  
    00007FF7B8C112BF  mov         dword ptr [rsp+30h],ebx  
    00007FF7B8C112C3  mov         rcx,rax  
    00007FF7B8C112C6  call        std::operator<<<char,std::char_traits<char>,32> (07FF7B8C115A0h)  
    00007FF7B8C112CB  mov         rcx,rax  
    00007FF7B8C112CE  mov         dl,0Ah  
    00007FF7B8C112D0  call        std::operator<<<std::char_traits<char> > (07FF7B8C113E0h)  
    		std::cout.flush();  // desperation
    00007FF7B8C112D5  mov         rcx,qword ptr [__imp_std::cout (07FF7B8C130B8h)]  
    00007FF7B8C112DC  call        qword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::flush (07FF7B8C130A8h)]  
    00007FF7B8C112E2  inc         rdi  
    00007FF7B8C112E5  rol         rbx,1  
    00007FF7B8C112E8  cmp         rdi,20h  
    00007FF7B8C112EC  jb          main+10h (07FF7B8C112A0h)  
    	}
    	std::cout.put('\n');
    00007FF7B8C112EE  mov         rcx,qword ptr [__imp_std::cout (07FF7B8C130B8h)]  
    00007FF7B8C112F5  mov         dl,0Ah  
    00007FF7B8C112F7  call        qword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::put (07FF7B8C130F0h)]  
    }
    00007FF7B8C112FD  mov         rbx,qword ptr [rsp+38h]  
    00007FF7B8C11302  xor         eax,eax  
    00007FF7B8C11304  add         rsp,20h  
    00007FF7B8C11308  pop         rdi  
    00007FF7B8C11309  ret  
    


  • @SeppJ Am C++-input irgendwas auszusetzten was phöse ausgehen könnte?


  • Mod

    Ich sehe nichts offensichtliches. Riecht nach einem Fehler im Bitset, aber so einen krassen Fehler würde ich einem großen Compiler eigentlich nicht zutrauen



  • Mit bitset scheint es nichts zu tun zu haben. Es tritt selbst bei der einfachsten Schleife auf:

    #include <iostream>
    
    int main()
    {
    	for (std::size_t i = 0; i < 32; i++)
    	{
    		std::cout << i << std::endl;
    	}
    }
    


  • @Swordfish sagte in cl goin crazy??:

    std::bitset<digits>{ 1ull << i }

    Was kommt heraus wenn du den obigen Teil in eine Variable auslagerst?



  • Das Verhalten ist auch anders wenn man es mit F5 oder mit STRG + F5 ausführt. Der Bug tritt nur ohne Debugger auf. Vielleicht gar kein Fehler im Compiler sondern im Runner. Oder das neue Terminal.



  • @Quiche-Lorraine schon probiert. dasselbe.



  • @servus_ dadsächlich. Mit debugger passts. Ich geh' bugreport schreiben.



  • Der Fehler tritt auch erst auf, wenn die Scrollbar des Terminals eingeblendet werden muss 😃
    Also bei ca. 30 Zeilen.



  • @servus_ sagte in cl goin crazy??:

    Der Fehler tritt auch erst auf, wenn die Scrollbar des Terminals eingeblendet werden muss 😃
    Also bei ca. 30 Zeilen.

    Klingt jetzt stark, dass das Terminal hier Probleme hat.
    Tritt es auch auf wenn man das test programm unter cmd.exe oder powershell startet?
    Dadurch könnte man eventuell herausfinden ob es wirklich am neuen Terminal liegt.



  • @firefly sagte in cl goin crazy??:

    @servus_ sagte in cl goin crazy??:

    Der Fehler tritt auch erst auf, wenn die Scrollbar des Terminals eingeblendet werden muss 😃
    Also bei ca. 30 Zeilen.

    Klingt jetzt stark, dass das Terminal hier Probleme hat.
    Tritt es auch auf wenn man das test programm unter cmd.exe oder powershell startet?
    Dadurch könnte man eventuell herausfinden ob es wirklich am neuen Terminal liegt.

    In einem selbst geöffneten Terminal gibt es auch keine Probleme. Visual Studio scheint schon mit beteiligt zu sein. 🙂

    Selbst wenn man ohne Debugger startet, steht im Terminal als Titel "Microsoft Visual Studio Debug Console".

    Ich vermute, dass der Fehler in folgendem Programm liegt:

    C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\Terminal\ServiceHub\os64\OpenConsole.exe



  • @servus_ sagte in cl goin crazy??:

    @firefly sagte in cl goin crazy??:

    @servus_ sagte in cl goin crazy??:

    Der Fehler tritt auch erst auf, wenn die Scrollbar des Terminals eingeblendet werden muss 😃
    Also bei ca. 30 Zeilen.

    Klingt jetzt stark, dass das Terminal hier Probleme hat.
    Tritt es auch auf wenn man das test programm unter cmd.exe oder powershell startet?
    Dadurch könnte man eventuell herausfinden ob es wirklich am neuen Terminal liegt.

    In einem selbst geöffneten Terminal gibt es auch keine Probleme. Visual Studio scheint schon mit beteiligt zu sein. 🙂

    Selbst wenn man ohne Debugger startet, steht im Terminal als Titel "Microsoft Visual Studio Debug Console". Da ist wohl der Fehler.

    Ist doch gut wenn man was ausschließen kann 😉



  • @firefly sagte in cl goin crazy??:

    Tritt es auch auf wenn man das test programm unter cmd.exe oder powershell startet?

    in cmd.exe alles gut.


Anmelden zum Antworten