geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
223 stars 235 forks source link

fix uninitialized variables #5774

Closed tjhei closed 4 months ago

tjhei commented 4 months ago

fixes #5763

tjhei commented 4 months ago

I am not sure this is the right thing to do or if we need to initialize with invalid values, but this makes the warnings go away...

tjhei commented 4 months ago

If it doesn't have one, it needs to be added.

It is a struct without any constructor or functions:

https://github.com/geodynamics/aspect/blob/d87c3c8df59ec5c479b94bfad8a3ff3d702c0eb2/include/aspect/material_model/rheology/diffusion_creep.h#L40-L51

By your logic, wouldn't this become a class if you add constructors to it?

bangerth commented 4 months ago

The difference in initialization of structures with

  MyStruct s;

and

  MyStruct s{};

and

  MyStruct s = {};

is so convoluted and ununderstandable that I'm opposed to it. Let's add a constructor to the class that avoids the issue.

tjhei commented 4 months ago

Let's add a constructor to the class that avoids the issue.

NaNs or 0.0 for doubles?

gassmoeller commented 4 months ago

NaN's If anyone uses this without initialization it is wrong.

bangerth commented 4 months ago

Yes, sNaNs.

tjhei commented 4 months ago

updated.

bangerth commented 4 months ago

Might as well squash/fixup, though.