Skip to content

Variable Shadowing Bug in leccalc/aggreports.cpp (Lines 1312-1315) #405

@FangWeihua

Description

@FangWeihua

Issue Description

In the file leccalc/aggreports.cpp, at lines 1312‑1315, there is a variable shadowing issue that leads to the fileIDs vector remaining empty after the conditional block.

std::vector<int> fileIDs;  // Outer declaration
if (outputFlags_[handles[WHEATSHEAF]] == true) {
    std::vector<int> fileIDs = GetFileIDs(handles[WHEATSHEAF], PSEPT);  // Inner declaration – shadows the outer one
}
// Here 'fileIDs' is still empty

The code currently declares std::vector<int> fileIDs outside an if block, then inside the block re‑declares a new local variable with the same name (std::vector<int> fileIDs = ...).

This local variable inside the if scope is destroyed when the block ends, leaving the outer fileIDs unchanged (still empty). Later code that depends on fileIDs being populated will therefore fail or behave incorrectly.

Expected behavior
The inner assignment should modify the outer fileIDs variable, not create a new local one.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

On Hold

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions