Skip to content

eamxx: fix uninit var warnings#8484

Merged
bartgol merged 1 commit into
masterfrom
copilot/eamxx-fix-uninit-var-warnings
Jul 15, 2026
Merged

eamxx: fix uninit var warnings#8484
bartgol merged 1 commit into
masterfrom
copilot/eamxx-fix-uninit-var-warnings

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes -Wsometimes-uninitialized and -Wunused-function compiler warnings that can produce undefined behavior depending on control flow.

Changes

  • atmosphere_driver.cpp: Initialize fail_handling_type to CheckFailHandling::Warning and lev to LogLevel::info at declaration so the compiler can confirm they are always initialized before use, even though the else branches call EKAT_ERROR_MSG.

  • field_pyutils.hpp: Initialize data = nullptr; the switch has no default assignment, leaving data uninitialized if an unrecognized type reaches the py::array(...) call.

  • ComposeTransportImplEnhancedTrajectoryImpl.hpp: Change KOKKOS_FUNCTIONKOKKOS_INLINE_FUNCTION for calc_vel_horiz_formula_node_ref_mid and calc_eta_dot_formula_node_ref_int. Both functions are used in ComposeTransportImplEnhancedTrajectory.cpp, but the header is also included by the test TU which does not call them — inline suppresses the per-TU unused-function diagnostic.

@mahf708 mahf708 requested a review from bartgol June 17, 2026 15:22
Copilot AI changed the title [WIP] Fix uninitialized variable warnings in C++ eamxx: fix uninit var warnings Jun 17, 2026
Copilot AI requested a review from mahf708 June 17, 2026 15:24
@mahf708 mahf708 added the CI: approved Allow gh actions PR testing on ghci-snl-* machines label Jun 17, 2026
@mahf708 mahf708 marked this pull request as ready for review June 17, 2026 21:46
@rljacob rljacob added the EAMxx C++ based E3SM atmosphere model (aka SCREAM) label Jun 23, 2026
@mahf708 mahf708 removed their request for review June 23, 2026 17:15
@bartgol bartgol marked this pull request as draft June 25, 2026 15:55
@bartgol bartgol marked this pull request as ready for review June 25, 2026 15:55
Initialize fail_handling_type and lev to safe defaults to suppress
-Wsometimes-uninitialized in atmosphere_driver.cpp.
Initialize data = nullptr in field_pyutils.hpp switch default case.
Change KOKKOS_FUNCTION to KOKKOS_INLINE_FUNCTION for
calc_vel_horiz_formula_node_ref_mid and
calc_eta_dot_formula_node_ref_int in
ComposeTransportImplEnhancedTrajectoryImpl.hpp to suppress
-Wunused-function when included in translation units that don't
call these functions.
@bartgol bartgol force-pushed the copilot/eamxx-fix-uninit-var-warnings branch from 7d88b17 to c5c7b55 Compare July 15, 2026 15:35
@bartgol bartgol added the BFB PR leaves answers BFB label Jul 15, 2026
bartgol added a commit that referenced this pull request Jul 15, 2026
)

Fixes -Wsometimes-uninitialized and -Wunused-function compiler warnings
that can produce undefined behavior depending on control flow.

[BFB]
@bartgol bartgol merged commit 447d95a into master Jul 15, 2026
13 of 14 checks passed
@bartgol bartgol deleted the copilot/eamxx-fix-uninit-var-warnings branch July 15, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BFB PR leaves answers BFB CI: approved Allow gh actions PR testing on ghci-snl-* machines EAMxx C++ based E3SM atmosphere model (aka SCREAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants