Menu

#1058 Compilation error CB20 in optimization modes O1-O3

Undefined
invalid
None
Undefined
2021-01-12
2021-01-11
dmanx
No

The program runs without errors in CB16, CB17 with any optimization settings O1-O3.
In CB20, any optimization O1-O3 will cause the program to crash or infinity loop.
It works without errors only with completely disabled optimization.

The flResultE procedure from the dll is called multiple times in a loop.
The number of GNC loops is set by keyboard input.

for (indx = 0; indx <= GNC; indx++)
{
flResultE(Func,res);
}

Disassembling in the case of optimization in CB20(GCC) is very strange.

1 - O1-O3 optimization
The loop is compiled without comparison commands and conditional exit at the end. Leads to infinity loop.

BeginLoop:
mov %ebx,04x(%esp)
...
call    
...
jmp  BeginLoop

2 - No optimization. Works without error.
At the beginning of the cycle, there is a check for completion.

BeginLoop:
mov 0x5312a4,%eax
cmp
jg exit
...
call 
...
jmp  BeginLoop 
exit:


Where is the mistake?
1 Attachments

Discussion

  • Teodor Petrov

    Teodor Petrov - 2021-01-11
    • status: open --> invalid
    • assigned_to: Morten MacFly --> Teodor Petrov
     
  • Teodor Petrov

    Teodor Petrov - 2021-01-11

    Sorry but C::B is not a compiler. It just runs the compiler/linker you've selected. So the problem is not in C::B...

    20.03 ships with a new compiler. Newer GCC and Clang are more aggressive when optimizing. They rarely have bugs which users can exposes in simple code (at least the versions on linux, GCC on windows is more buggy), most of the times they are starting to explore some new undefined behaviour in your code, which breaks it. So inspect your code for UBs and if there aren't any report it to the compiler vendor. They'll require a minimal repro, probably and not a vague description of the problem.

     
  • dmanx

    dmanx - 2021-01-12

    The compiler in CB20 use is the default built-in compiler for Windows. No errors occurred in CB16, CB17. Who is the compiler vendor for CB20? You could sent link to their site on sourceforge?

     
  • Teodor Petrov

    Teodor Petrov - 2021-01-12

    Microsoft doesn't ship a compiler with Windows.

    You've installed your current compiler as part of CB's installation or you've installed it separately.
    You've not told us what you have installed or how have you installed it. So we could only guess.

    The version shipping with 20.03 is provided by the mingw-w64 project. The one in 17.12 or older is provided by TDM.

    Nothing stops you from using the old compiler. You have to just install it and then set it up.

     
  • dmanx

    dmanx - 2021-01-12

    I am using a 32 bit compiler which was recently updated by see
    https://sourceforge.net/p/codeblocks/tickets/1048/

    In folder
    https://sourceforge.net/projects/codeblocks/files/Binaries/20.03/Windows/32bit/
    two 32 bit compilers are specified. What kind of compiler is there and how they differ from each other, I still do not understand.
    codeblocks-20.03-32bit-mingw-32bit-setup.exe
    codeblocks-20.03-32bit-setup.exe

    I am using the first one.
    When requesting TDM, which compiler (and version) should I specify?

     

Log in to post a comment.

MongoDB Logo MongoDB