fix(globals): Globals methods operate on this-> not global g#83
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Several
Globalsmember functions insrc/globals.cppread and wrote configuration fields through the global instanceg(e.g.g.cmd,g.verbosity,g.max_size) rather thanthis->. This is a latent defect: those methods only behave correctly when invoked on the global instanceg. Called on any otherGlobalsinstance, they would read from and mutateginstead of that instance.Affected methods:
init_timers()— appended tog.timersparse_args()— read/wroteg.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 fromg.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_ramFix
Converted every active
g.<member>reference insideGlobalsmember functions tothis-><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:
No warnings or errors.
Fixes #69
Sub-issue of #45 (D2 §6 defect #11).