Skip to content

Uninitialized variables test_by_fit_rule and test_by_test_rule #83

@BartMassey

Description

@BartMassey

Location

File: cpp/ReportPrintConditionalDV.cpp:762
Function: Report::printConditional_DV()

Issue

Variables test_by_fit_rule and test_by_test_rule are used with += operator in a loop without prior initialization.

Code

double test_by_fit_rule, test_by_test_rule;  // Line 762: declared but not initialized

// Later in code (lines 765-773):
for (int i = 0; i < iv_statespace; i++) {
    // ...
    test_by_fit_rule += test_freq[i][fit_rule[i]];      // Line 772: += on uninitialized
    test_by_test_rule += test_freq[i][test_rule[i]];    // Line 773: += on uninitialized
}

// Line 1095-1096: Used in calculation
fit_percent_on_test = test_by_fit_rule / test_sample_size * 100.0;
best_percent_on_test = test_by_test_rule / test_sample_size * 100.0;

Risk

High - Undefined behavior if iv_statespace is zero or if loop doesn't execute. Results in incorrect statistics calculations.

Recommended Fix

double test_by_fit_rule = 0.0, test_by_test_rule = 0.0;

Reference

See docs/compiler-warning-analysis.md for detailed analysis (Category 4: Test Statistics).

Priority: High
Type: Bug - Undefined Behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions