Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Patches for clean Fedora RPM builds that pass unit tests #123

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
10 changes: 6 additions & 4 deletions libsrc/general/ngarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,9 @@ namespace netgen
/// if responsible, deletes memory
~NgArray()
{
if (ownmem)
delete [] data;
if (data)
if (ownmem)
delete [] data;
Comment on lines -298 to +300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not make any sense. When data is a nullptr, then the delete [] is a noop.
Dito below.

Maybe the actual problem was fixed with 5423242

Copy link
Author

@xiphmont xiphmont Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ has somehow continued to make behavior of delete nullptr ambiguous, and gcc/glibc crash on this if they're built with object instance nullptr checking disabled. Unfortunately, that's now the default config on RedHat-style distros since F35.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an object instance nullptr (*this), but a regular delete [].
If this breaks on Fedora, they are doing something wrong.

https://isocpp.org/wiki/faq/freestore-mgmt#delete-handles-null

Do I need to check for null before delete p?
No!

}

/// Change logical size. If necessary, do reallocation. Keeps contents.
Expand Down Expand Up @@ -374,8 +375,9 @@ namespace netgen
/// Deallocate memory
void DeleteAll ()
{
if (ownmem)
delete [] data;
if (data)
if (ownmem)
delete [] data;
data = 0;
size = allocsize = 0;
}
Expand Down