Skip to content

cpp func_start: False positives from lambdas in constructors and member-initializer-lists #2013

Closed

Description

@squid-protocol

Summary

GitGalaxy's C++ func_start regex (gitgalaxy/standards/language_standards.py) misidentifies constructor calls and member-initializer-list entries that use lambda expressions as if they were real function definitions. The regex sees the shape identifier(...) { ... } and cannot distinguish a genuine function definition from:

  • A constructor's member-initializer-list entry assigning a lambda: m_member([capture]() { ... body ... }),
  • A constructor call with a lambda argument: std::thread([capture]() { ... body ... }).detach();

The regex matches the lambda's opening { as if it were the "function body" opener following the identifier and parentheses, producing spurious function entries in the extraction DB.

Confirmed instances in language-crucible/data/cpp/

Case 1: Member-initializer-list lambda

  • File: powertoys/FancyZones.cpp:75
  • Source:
    m_draggingState([this]() {
        ...lambda body...
    }),
  • GitGalaxy spuriously claims a function named m_draggingState exists at this line.
  • Reality: m_draggingState is a plain member variable declared at powertoys/FancyZones.cpp:181 as DraggingState m_draggingState; — this is a constructor initializing it with a lambda-returning-something, not a function definition.
  • Both ctags and tree-sitter correctly identify this as non-function code; only GitGalaxy is fooled.

Case 2: Constructor call with lambda argument

  • File: powertoys/main.cpp:88
  • Source:
    std::thread([skipSettingsCheck]() {
        ...lambda body...
    }).detach();
  • GitGalaxy spuriously claims a function named std::thread exists at this line.
  • Reality: This is a std::thread constructor call taking a lambda argument, not a function definition named std::thread.
  • Three additional identical instances exist at powertoys/main.cpp:211 and 221 (all variations of std::thread{ [...] { ... } }).
  • Neither ctags nor tree-sitter report these as function definitions.

Impact

Suggested fix

This requires the same careful, full-corpus-verified treatment as the related C++ issues from this sweep (#2009, #2010, #2011, #2012):

  1. Identify the exact regex branch: Locate the func_start pattern segment responsible — likely the generic identifier-then-parens-then-brace matching that has no way to distinguish a constructor-call/initializer-list entry from a real declarator.

  2. Consider lambda-body detection: Explore whether a lambda-body brace can be reliably distinguished from a real function body brace at the regex level — for example:

    • Detecting [...] (capture-list brackets) immediately after the opening ( as a signal this is a lambda, not a function signature.
    • Verifying this pattern doesn't create new false negatives on valid lambdas within function bodies.
  3. Full Differential Scan verification: Do not attempt a quick patch.

    • Add extraction gauntlet regression tests to tests/extraction/languages/test_cpp.py covering both patterns (initializer-list lambda and constructor-call lambda).
    • Run python tests/tools/crucible_check.py --update against the full ~80-repo corpus.
    • Re-bless both tests/golden_master_audit.json and tests/golden_master_zero_dep_audit.json.
    • Verify the fix leaves no new false positives elsewhere in C++ code.

Cross-references: Issues #2009, #2010, #2011, #2012 (all C++ func_start/args, filed 2026-08-21) are related but address distinct bugs (false negatives, args miscounting) — this is a false-positive issue.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-positive
    on Aug 21, 2026
  2. added this to the v2.4.9 milestone on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginepriority: mediumtestingthreat: false-positive

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions