Skip to content

fix(Simulation): avoid GCC dangling-reference errors on absl::Span - #206

Merged
BenPinet merged 1 commit into
nextfrom
fix/gcc-dangling-reference
Oct 23, 2026
Merged

BenPinet merged 1 commit into
nextfrom
fix/gcc-dangling-reference

Conversation

@francoisbonneau

Copy link
Copy Markdown
Member

Builds with GCC 13+ fail under -Werror with -Wdangling-reference when taking a reference to an element of a temporary absl::Span (e.g. problem.materials()[id]). The reference points into the owner's storage, so it is a false positive.

This stores the span in a local before taking the element reference. No behaviour change.

Companion PR in OpenGeode-GeosciencesIO on branch fix/gcc-dangling-reference.

🤖 Generated with Claude Code

… errors

GCC 13+ reports -Wdangling-reference when taking a reference to an
element of a temporary absl::Span. The reference points into the
owner's storage, so it is a false positive, but it breaks -Werror builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v21.1.8) reports: 5 concern(s)
  • src/geode/geosciences/simulation/helpers/physical_problem_validation.cpp:122:49: warning: [cppcoreguidelines-pro-bounds-array-to-pointer-decay]

    do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead

      122 |             issues_.emplace_back( absl::StrCat( args... ) );
          |                                                 ^
  • src/geode/geosciences/simulation/helpers/physical_problem_validation.cpp:125:9: warning: [modernize-use-nodiscard]

    function 'is_multiphase' should be marked [[nodiscard]]

      125 |         bool is_multiphase() const
          |         ^
          |         [[nodiscard]] 
  • src/geode/geosciences/simulation/helpers/physical_problem_validation.cpp:132:9: warning: [modernize-use-nodiscard]

    function 'fluid' should be marked [[nodiscard]]

      132 |         const geode::FluidModel& fluid() const
          |         ^
          |         [[nodiscard]] 
  • src/geode/geosciences/simulation/helpers/physical_problem_validation.cpp:154:17: warning: [readability-implicit-bool-conversion]

    implicit conversion 'const geode::SinglePhaseFlow *' -> 'bool'

      154 |             if( dynamic_cast< const geode::SinglePhaseFlow* >(
          |                 ^
          |                 (
      155 |                     &problem_.flow() )
          |                                       
          |                                        != nullptr)
  • src/geode/geosciences/simulation/helpers/physical_problem_validation.cpp:717:17: warning: [readability-implicit-bool-conversion]

    implicit conversion 'const geode::SinglePhaseFluid *' -> 'bool'

      717 |             if( single_phase && !single_phase->thermal() )
          |                 ^
          |                 (            != nullptr)

Have any feedback or feature suggestions? Share it here.

@BenPinet
BenPinet merged commit 8a5b8d0 into next Oct 23, 2026
26 checks passed
@BenPinet
BenPinet deleted the fix/gcc-dangling-reference branch October 23, 2026 10:22
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.

3 participants