llnl / llnl/mgmol

`nullptr` initialization of pointer member variables in class definition

Open
#223 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
47
Forks
15
Avg merge
12h 20m
Merged PRs (30d)
3

Description

Currently, mgmol classes do not initialize pointer member variables in their class definitions. For example of `MGMol`,

```
template
class MGmol : public MGmolInterface
{
private:
std::ostream& os_;

MPI_Comm comm_;

XConGrid* xcongrid_; // <--

OrbitalsType* current_orbitals_; // <--

AOMMprojector* aomm_; // <--

Ions* ions_; // <--

....
```

This is very error-prone and hard to debug, as they have uninitialized pointers which exhibit unexpected behaviors. This practice should be changed as soon as possible, as below:
```
template
class MGmol : public MGmolInterface
{
private:
std::ostream& os_;

MPI_Comm comm_;

XConGrid* xcongrid_ = nullptr;

OrbitalsType* current_orbitals_ = nullptr;

AOMMprojector* aomm_ = nullptr;

Ions* ions_ = nullptr;

....
```

This is usually the safest and shortest initialization. An alternative is to define them as `nullptr` in the constructor (For example, `MGmol::MGmol(...)`).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the MGmol class definition and its MGmol::MGmol(...) constructor, which the issue uses as examples. Inspect the pointer member declarations across the mgmol classes and identify which lack initialization. Done means the relevant pointer members are initialized to nullptr consistently; no tests or specific files are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.