Visual Studio Debug/Release differences Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Visual Studio Debug/Release differences

Post by doublemax »

Works for me with VS2017 in both debug and release mode.

I'm starting to suspect another bug in the VS2022 compiler like the one recently discovered in wxImage.
https://github.com/wxWidgets/wxWidgets/issues/23164

Could you switch off compiler optimization in the release config and try again?
Use the source, Luke!
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Visual Studio Debug/Release differences

Post by raananb »

I turned off all optimization values in the C++/Optimization panel, with no effect on result.

Below is the command line of C:C++ section of the project properties

/ifcOutput "VCProjectRelease\" /GS /W4 /Gy /Zc:wchar_t /I"D:\wxWidgets-3.2.1/lib/vc_x64_lib/mswu" /I"D:\wxWidgets-3.2.1/include" /I"D:\wxWidgets-3.2.1/contrib/include" /I"C:\Program Files (x86)\Windows Kits\10\include" /I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" /I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" /I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" /Zi /Gm- /Od /Fd"VCProjectRelease\vc143.pdb" /Zc:inline /fp:precise /D "NOPCH" /D "WIN32" /D "__WXMSW__" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /MT /FC /Fa"VCProjectRelease\" /EHsc /nologo /Fo"VCProjectRelease\" /Fp"VCProjectRelease\http.pch" /diagnostics:column
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Visual Studio Debug/Release differences

Post by doublemax »

raananb wrote: Sun Jan 22, 2023 12:19 pm I turned off all optimization values in the C++/Optimization panel, with no effect on result.
Too bad, that would have been an easy explanation.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Visual Studio Debug/Release differences

Post by ONEEYEMAN »

Hi,
Can you try to install MSVC 2017 and build the library and the code with it?
You don't have to uninstall the current one - they can co-exist.

If everything will be successful, we will know its a bug in the compiler

Thank you.
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Visual Studio Debug/Release differences

Post by raananb »

Had 2019 installed. Rebuilt application with it.

Application finds the file both in Debug and in Release mode.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Visual Studio Debug/Release differences

Post by ONEEYEMAN »

Hi,
File a bug with M$ about that. ;-)

Thank you.
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Visual Studio Debug/Release differences

Post by raananb »

Bug filed with Visual Studio plateform.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Visual Studio Debug/Release differences

Post by PB »

FWIW, I have tested the zipped project with MSVS 2022 Community v17.4.4 using 64-bit build of wxWidgets (recentish master, tested both shared and static builds) on WIndows 10 22H2.

Both Debug and Release builds show "File found" after clicking the button.

I did not use the provided MSVS solution and project (it did not build out of the box), so I just dropped all the files into my template wxWidgets project (see the attachment).

EDIT
BTW, does the error manifest for you only when using that complex project? AFAICT, the relevant code boils down to just this

Code: Select all

#include <wx/wx.h>
#include <wx/protocol/http.h>

#include <memory>

class MyApp: public wxApp
{
public:
    bool OnInit() override
    {
        wxHTTP http;

        if ( http.Connect("www.pixname.com") )
        {
            std::unique_ptr<wxInputStream> inStream(http.GetInputStream("/AccountsManager/AccountsManagerLatestVersion"));

            if ( inStream )
                wxLogMessage("File found.");
            else
                wxLogError("File not found.");
        }
        else
            wxLogError("Could not connect.");

        return false;
    }
}; wxIMPLEMENT_APP(MyApp);
EDIT 2
I also tried the original project and my code with wxWidgets 3.2.1, both still worked.
Attachments
http-PB.zip
(7.42 KiB) Downloaded 108 times
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Visual Studio Debug/Release differences

Post by raananb »

I went over the code in my Http.zip project, and made a curious discovery:

'httpapp.cpp' file contains the following sequence, automatically generated by DialogBlocks for all applications:

Code: Select all

bool HttpApp::OnInit()
{    
////@begin HttpApp initialisation
    // Remove the comment markers above and below this block
    // to make permanent changes to the code.

#if wxUSE_XPM
    wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
    wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
    wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
    wxImage::AddHandler(new wxGIFHandler);
#endif
    Principal* mainWindow = new Principal( NULL );
    mainWindow->Show(true);
////@end HttpApp initialisation

    return true;
}
if all the #if wxUSE ... #endif are commeneted out, the code works in both Debug and Release modes. If any of these statements is not commented, the Release version fails.

This does not solve the problem in my 'real' application, though.

It does lead one to suspect that there is a problem in code generation.
Post Reply