Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
warning: 'parent' may be used uninitialized when building ToolsPlus\shellpropert
(1/1)
ollydbg:
When building with GCC 11.1 compiler, I got such warning:
--- Code: ---[ 71.4%] g++.exe -Wall -pipe -mthreads -fmessage-length=0 -fexceptions -DWXUSINGDLL -DHAVE_W32API_H -D__WXMSW__ -D_WIN64 -DcbDEBUG -DNOPCH -DwxUSE_UNICODE -DBUILDING_PLUGIN -std=gnu++11 -g -I..\..\..\include -I..\..\..\include\tinyxml -I..\..\..\sdk\wxscintilla\include -Id:\code\wxWidgets-3.1.5\include -Id:\code\wxWidgets-3.1.5\lib\gcc_dll\mswu -c D:\code\cbsource\codeblocks_sf\src\plugins\contrib\ToolsPlus\shellproperties.cpp -o ..\..\..\.objs31_64\plugins\contrib\ToolsPlus\shellproperties.o
D:\code\cbsource\codeblocks_sf\src\plugins\contrib\ToolsPlus\se_globals.cpp: In function 'wxString GetParentDir(const wxString&)':
D:\code\cbsource\codeblocks_sf\src\plugins\contrib\ToolsPlus\se_globals.cpp:5:21: warning: 'parent' may be used uninitialized [-Wmaybe-uninitialized]
5 | wxString parent=wxFileName(parent).GetPath(0);
| ^~~~~~~~~~~~~~~~~~
In file included from D:\code\cbsource\codeblocks_sf\src\plugins\contrib\ToolsPlus\se_globals.h:12,
from D:\code\cbsource\codeblocks_sf\src\plugins\contrib\ToolsPlus\se_globals.cpp:1:
d:\code\wxWidgets-3.1.5\include/wx/filename.h:138:5: note: by argument 2 of type 'const wxString&' to 'wxFileName::wxFileName(const wxString&, wxPathFormat)' declared here
138 | wxFileName( const wxString& fullpath, wxPathFormat format = wxPATH_NATIVE )
| ^~~~~~~~~~
D:\code\cbsource\codeblocks_sf\src\plugins\contrib\ToolsPlus\se_globals.cpp:5:14: note: 'parent' declared here
5 | wxString parent=wxFileName(parent).GetPath(0);
| ^~~~~~
--- End code ---
I see the code is:
--- Code: ---wxString GetParentDir(const wxString &path)
{
wxString parent=wxFileName(parent).GetPath(0);
if(path==parent||parent.IsEmpty())
return wxEmptyString;
else
return parent;
}
--- End code ---
So, this is a bug?
I think
--- Code: ---wxString parent=wxFileName(parent).GetPath(0);
--- End code ---
should be
--- Code: ---wxString parent=wxFileName(path).GetPath(0);
--- End code ---
?
ollydbg:
--- Code: ---D:\code\cbsource\codeblocks_sf\src\plugins\contrib\FileManager\se_globals.cpp: In function 'wxString GetParentDir(const wxString&)':
D:\code\cbsource\codeblocks_sf\src\plugins\contrib\FileManager\se_globals.cpp:6:21: warning: 'parent' may be used uninitialized [-Wmaybe-uninitialized]
6 | wxString parent=wxFileName(parent).GetPath(0);
| ^~~~~~~~~~~~~~~~~~
In file included from D:\code\cbsource\codeblocks_sf\src\plugins\contrib\FileManager\se_globals.h:12,
from D:\code\cbsource\codeblocks_sf\src\plugins\contrib\FileManager\se_globals.cpp:2:
d:\code\wxWidgets-3.1.5\include/wx/filename.h:138:5: note: by argument 2 of type 'const wxString&' to 'wxFileName::wxFileName(const wxString&, wxPathFormat)' declared here
138 | wxFileName( const wxString& fullpath, wxPathFormat format = wxPATH_NATIVE )
| ^~~~~~~~~~
D:\code\cbsource\codeblocks_sf\src\plugins\contrib\FileManager\se_globals.cpp:6:14: note: 'parent' declared here
6 | wxString parent=wxFileName(parent).GetPath(0);
| ^~~~~~
--- End code ---
I see there is a similar warning in FileManager\se_globals.cpp.
There are two "se_globals.cpp" in our code base. :)
oBFusCATed:
Just fix it.
ollydbg:
--- Quote from: oBFusCATed on May 03, 2021, 04:41:14 pm ---Just fix it.
--- End quote ---
Fixed in r12318.
Navigation
[0] Message Index
Go to full version