Skip to content
Snippets Groups Projects

Remove forbidden downcast

Merged Carsten Gräser requested to merge feature/remove-forbidden-downcast into master
2 files
+ 0
97
Compare changes
  • Side-by-side
  • Inline
Files
2
  • c5e023c5
    These constructors and assignments from base class are
    all using a downcast which may result in undefined behaviour.
    Since this is potentially dangerous and not used anywhere
    in the core modules, this patch removes those methods.
+ 0
27
@@ -426,27 +426,6 @@ namespace Dune {
for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
}
//! construct from base class object
base_array (const base_array_unmanaged<B,A>& _a)
{
const base_array& a = static_cast<const base_array&>(_a);
// allocate memory with same size as a
this->n = a.n;
if (this->n>0) {
this->p = allocator_.allocate(this->n);
new (this->p)B[this->n];
} else
{
this->n = 0;
this->p = 0;
}
// and copy elements
for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
}
//! free dynamic memory
~base_array ()
{
@@ -510,12 +489,6 @@ namespace Dune {
return *this;
}
//! assign from base class object
base_array& operator= (const base_array_unmanaged<B,A>& a)
{
return this->operator=(static_cast<const base_array&>(a));
}
protected:
A allocator_;
Loading