diff options
author | Omair Majid <omajid@redhat.com> | 2019-06-07 16:49:52 -0400 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2019-06-07 22:49:52 +0200 |
commit | 3fcaf0373369ed4b17bd1ed068592c2e0cec3997 (patch) | |
tree | a751b81233e46f1163ffd2bacf31697cea72231c /src/ilasm | |
parent | b314ed86b11756834b0936e56c3d841e7407f81d (diff) | |
download | coreclr-3fcaf0373369ed4b17bd1ed068592c2e0cec3997.tar.gz coreclr-3fcaf0373369ed4b17bd1ed068592c2e0cec3997.tar.bz2 coreclr-3fcaf0373369ed4b17bd1ed068592c2e0cec3997.zip |
Do not delete polymorphic objects without a virtual destructor (#23705)
SEI CERT C++ Coding Standard says:
> Do not delete an object of derived class type through a pointer to its
> base class type that has a non-virtual destructor. Instead, the base
> class should be defined with a virtual destructor. Deleting an object
> through a pointer to a type without a virtual destructor results in
> undefined behavior.
See https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP52-CPP.+Do+not+delete+a+polymorphic+object+without+a+virtual+destructor
Clang generally warns about this, but we disabled the warning via
-Wno-delete-non-virtual-dtor. This commit re-enables the warning and
fixes up all the code that hits the warning.
Diffstat (limited to 'src/ilasm')
-rw-r--r-- | src/ilasm/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/ilasm/asmparse.h | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/ilasm/CMakeLists.txt b/src/ilasm/CMakeLists.txt index f780dcae11..6117030dcc 100644 --- a/src/ilasm/CMakeLists.txt +++ b/src/ilasm/CMakeLists.txt @@ -51,7 +51,7 @@ if(CLR_CMAKE_PLATFORM_UNIX) # Need generate a right form of asmparse.cpp to avoid the following options. # Clang also produces a bad-codegen on this prebuilt file with optimization. # https://github.com/dotnet/coreclr/issues/2305 - add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor;-Wno-register>") + add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-register>") add_compile_options(-Wno-array-bounds) add_compile_options(-Wno-unused-label) set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" ) diff --git a/src/ilasm/asmparse.h b/src/ilasm/asmparse.h index 3c18f35a75..9d0c841d53 100644 --- a/src/ilasm/asmparse.h +++ b/src/ilasm/asmparse.h @@ -19,6 +19,8 @@ class ReadStream { public: + virtual ~ReadStream() = default; + virtual unsigned getAll(__out char** ppch) = 0; // read at most 'buffLen' bytes into 'buff', Return the @@ -276,7 +278,7 @@ class AsmParse : public ErrorReporter { public: AsmParse(ReadStream* stream, Assembler *aAssem); - ~AsmParse(); + virtual ~AsmParse(); void CreateEnvironment(ReadStream* stream); void ParseFile(ReadStream* stream); // The parser knows how to put line numbers on things and report the error |