Skip to content

v0.23.0 does not build with AppleClang 15: a lambda captures a structured binding #228

Closed

Description

@SizzleUnrlsd

v0.23.0 does not build with AppleClang 15 (Xcode 15.4), the default compiler of GitHub's macos-14 runner. src/app/AnalyzerApp.cpp:1090 captures a structured binding in a lambda, a C++20 feature that AppleClang supports only from version 16. This CI does not catch it, because macos-latest has a newer Xcode.

Observed

CoreTrace's CI, Build on macos-14, on CoreTrace/coretrace#194 (the update to v0.23.0):

/Users/runner/work/coretrace/coretrace/build/_deps/stack_analyzer-src/src/app/AnalyzerApp.cpp:1090:66: error: reference to local binding 'wrapper' declared in enclosing function 'analyzeWithSharedModuleLoading'
                                  [&](const auto& pair) { return wrapper.pairs.count(pair) == 0; });
                                                                 ^
/Users/runner/work/coretrace/coretrace/build/_deps/stack_analyzer-src/src/app/AnalyzerApp.cpp:1079:43: note: 'wrapper' declared here
                for (const auto& [symbol, wrapper] :

The capture comes from 5010817 ("determinism and length pairs follow calls into other files"), after v0.22.0, which still builds there.

It is the only one. Compiling the 51 translation units of v0.23.0 with -Wpre-c++20-compat reports a single "captured structured bindings" warning, at that line.

Change

Capture the member rather than the binding:

std::erase_if(common.pairs, [&pairs = wrapper.pairs](const auto& pair)
              { return pairs.count(pair) == 0; });

The predicate is the same. With this change, -Wpre-c++20-compat reports no capture in that file.

Acceptance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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