Skip to content

fix(globals): Globals methods operate on this-> not global g#83

Merged
TimD1 merged 2 commits into
devfrom
69_D2_td_init-timers-this
Jul 18, 2026
Merged

fix(globals): Globals methods operate on this-> not global g#83
TimD1 merged 2 commits into
devfrom
69_D2_td_init-timers-this

Conversation

@TimD1

@TimD1 TimD1 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Root cause

Several Globals member functions in src/globals.cpp read and wrote configuration fields through the global instance g (e.g. g.cmd, g.verbosity, g.max_size) rather than this->. This is a latent defect: those methods only behave correctly when invoked on the global instance g. Called on any other Globals instance, they would read from and mutate g instead of that instance.

Affected methods:

  • init_timers() — appended to g.timers
  • parse_args() — read/wrote g.cmd, g.verbosity, g.write, and the final validation checks (g.max_qual, g.min_qual, g.max_size, g.sv_threshold, g.max_supercluster_size)
  • print_usage() — printed defaults from g.verbosity, g.max_size, g.sv_threshold, g.min_qual, g.max_qual, g.max_supercluster_size, g.credit_threshold, g.max_dist, g.max_threads, g.max_ram

Fix

Converted every active g.<member> reference inside Globals member functions to this-><member> — 25 references across the three methods. Commented-out dead code (the disabled --max-iterations, --mismatch-penalty, etc. usage lines) is left untouched.

Behavior impact

Unchanged in production, since these methods are always invoked on the global g. The class is now correct for any instance.

Verification

Compiles clean:

g++ -c -g -O1 -Wall -Wextra -std=c++17 globals.cpp

No warnings or errors.


Fixes #69
Sub-issue of #45 (D2 §6 defect #11).

TimD1 added 2 commits July 17, 2026 22:01
Extends the init_timers fix to every remaining leftover global reference
in Globals member functions. parse_args() and print_usage() read/wrote
fields through the global instance g instead of this->, so both methods
only behaved correctly when invoked on g. Converts all 24 active
g.<member> references to this-><member>; commented-out dead code is
left untouched.

Behavior is unchanged in production (both methods are only ever called
on the global g), but the class is now correct for any instance.

Compiles clean:
  g++ -c -g -O1 -Wall -Wextra -std=c++17 globals.cpp
@TimD1 TimD1 changed the title fix(globals): init_timers operates on this->timers fix(globals): Globals methods operate on this-> not global g Jul 18, 2026
@TimD1
TimD1 merged commit a049cc4 into dev Jul 18, 2026
1 check passed
@TimD1
TimD1 deleted the 69_D2_td_init-timers-this branch July 18, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant