Warnings in if_ole.cpp

83 views
Skip to first unread message

Axel Bender

unread,
Feb 17, 2016, 3:01:43 AM2/17/16
to vim_dev
Compiling gvim (Windows 7, gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 4.8.4) the following warning appears in if_ole.cpp:

gcc -Iproto -DWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DHAVE_PATHDEF -DFEAT_BIG -DMS_WIN64 -DHAVE_GETTEXT -DHAVE_LOCALE_H -DDYNAMIC_GETTEXT -DFEAT_OLE -DFEAT_CSCOPE -DFEAT_CHANNEL -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -march=x86-64 -Wall -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python32.dll\" -DFEAT_XPM_W32 -I xpm/x64/include -I xpm/x64/../include -O3 -fomit-frame-pointer -freg-struct-return -s -c -o gobjx86-64/if_ole.o if_ole.cpp

if_ole.cpp: In static member function 'static CVim* CVim::Create(int*)':
if_ole.cpp:163:13: warning: deleting object of polymorphic class type 'CVim' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete me;
^
if_ole.cpp:171:13: warning: deleting object of polymorphic class type 'CVim' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete me;
^
if_ole.cpp:184:13: warning: deleting object of polymorphic class type 'CVim' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete me;
^
if_ole.cpp:197:9: warning: deleting object of polymorphic class type 'CVim' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete me;
^
if_ole.cpp: In function 'void UninitOLE()':
if_ole.cpp:795:9: warning: deleting object of polymorphic class type 'CVim' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete app;
^
if_ole.cpp:802:9: warning: deleting object of polymorphic class type 'CVimCF' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete cf;
^

Bram Moolenaar

unread,
Feb 17, 2016, 2:48:46 PM2/17/16
to Axel Bender, vim_dev

Axel Bender wrote:

> Compiling gvim (Windows 7, gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 p=
> roject) 4.8.4) the following warning appears in if_ole.cpp:
>
> gcc -Iproto -DWIN32 -DWINVER=3D0x0500 -D_WIN32_WINNT=3D0x0500 -DHAVE_PATHDE=
> F -DFEAT_BIG -DMS_WIN64 -DHAVE_GETTEXT -DHAVE_LOCALE_H -DDYNAMIC_GETTEXT -D=
> FEAT_OLE -DFEAT_CSCOPE -DFEAT_CHANNEL -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEA=
> T_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -march=3Dx86-6=
> 4 -Wall -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=3D\"python32=
> .dll\" -DFEAT_XPM_W32 -I xpm/x64/include -I xpm/x64/../include -O3 -fomit-f=
> rame-pointer -freg-struct-return -s -c -o gobjx86-64/if_ole.o if_ole.cpp
>
> if_ole.cpp: In static member function 'static CVim* CVim::Create(int*)':
> if_ole.cpp:163:13: warning: deleting object of polymorphic class type 'CVim=
> ' which has non-virtual destructor might cause undefined behaviour [-Wdelet=
> e-non-virtual-dtor]
> delete me;
> ^
> if_ole.cpp:171:13: warning: deleting object of polymorphic class type 'CVim=
> ' which has non-virtual destructor might cause undefined behaviour [-Wdelet=
> e-non-virtual-dtor]
> delete me;
> ^
> if_ole.cpp:184:13: warning: deleting object of polymorphic class type 'CVim=
> ' which has non-virtual destructor might cause undefined behaviour [-Wdelet=
> e-non-virtual-dtor]
> delete me;
> ^
> if_ole.cpp:197:9: warning: deleting object of polymorphic class type 'CVim'=
> which has non-virtual destructor might cause undefined behaviour [-Wdelete=
> -non-virtual-dtor]
> delete me;
> ^
> if_ole.cpp: In function 'void UninitOLE()':
> if_ole.cpp:795:9: warning: deleting object of polymorphic class type 'CVim'=
> which has non-virtual destructor might cause undefined behaviour [-Wdelete=
> -non-virtual-dtor]
> delete app;
> ^
> if_ole.cpp:802:9: warning: deleting object of polymorphic class type 'CVimC=
> F' which has non-virtual destructor might cause undefined behaviour [-Wdele=
> te-non-virtual-dtor]
> delete cf;
> ^

Does anyone know how to avoid these warnings?

--
GALAHAD: No. Look, I can tackle this lot single-handed!
GIRLS: Yes, yes, let him Tackle us single-handed!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Andrei Olsen

unread,
Feb 17, 2016, 7:11:21 PM2/17/16
to vim_dev, axel....@cip-kommunal.de
On Wednesday, February 17, 2016 at 8:48:46 PM UTC+1, Bram Moolenaar wrote:
> Does anyone know how to avoid these warnings?

This should help:
https://gcc.gnu.org/wiki/VerboseDiagnostics#delete-non-virtual-dtor

PS: you also have this one:

gui_dwrite.cpp:348:13: warning: deleting object of polymorphic class type 'GdiTextRenderer' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete this;
^

Ken Takata

unread,
Feb 18, 2016, 9:32:49 AM2/18/16
to vim_dev, axel....@cip-kommunal.de
Hi,

These warnings are all false positive because we don't inherit the classes.
I think there are two options to suppress the warnings:

1. Add "virtual" to the each destructor. Or,
2. Use "final" specifier which is available from C++11.
(See the attached patch.)


Regards,
Ken Takata

fix-mingw-cxx-warnings.patch
Reply all
Reply to author
Forward
0 new messages