Skip to content

[PWGEM] Fix casts - #18387

Draft
vkucera wants to merge 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGEM
Draft

vkucera wants to merge 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGEM

Conversation

@vkucera

@vkucera vkucera commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes C-style, redundant, wrong, and dangerous casts (found by Clang-Tidy and cpplint).

  • Remove redundant casts. (readability-redundant-casting)
  • Remove const_cast. (cppcoreguidelines-pro-type-const-cast)
  • Replace C-style casts with static_cast. (google-readability-casting, cpplint: readability/casting)
  • Replace unsafe C-style casts with dynamic_cast. (cppcoreguidelines-pro-type-cstyle-cast)
  • Replace static_cast in downcasts with dynamic_cast. (cppcoreguidelines-pro-type-static-cast-downcast)
  • Replace reinterpret_cast with static_cast or dynamic_cast. (cppcoreguidelines-pro-type-reinterpret-cast)
  • Replace two-step casting through void* with reinterpret_cast. (bugprone-casting-through-void)

@github-actions

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 5688 warnings, 🔕 28 disabled

@github-actions github-actions Bot added pwgem photon Photon and neutral meson PAG label labels Oct 21, 2026
@github-actions github-actions Bot changed the title Fix casts [PWGEM] Fix casts Oct 21, 2026
@vkucera
vkucera marked this pull request as ready for review October 21, 2026 17:24
@alibuild

alibuild commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for a25d7ca at 2026-10-22 01:46:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'To reproduce the results below locally, run: '\''aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'\''.'
To reproduce the results below locally, run: 'aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'.
++ echo 'To apply all automatic fixes, add the '\''-e O2PHYSICS_CHECKER_FIX=1'\'' option.'
To apply all automatic fixes, add the '-e O2PHYSICS_CHECKER_FIX=1' option.
++ echo 'See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.'
See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.
++ echo 'Found 5 errors and 1020 warnings.'
Found 5 errors and 1020 warnings.
++ [[ 5 -gt 0 ]]
++ cat /sw/BUILD/6aa877c35271b694a434df60339b7cc39d2ae59c/O2Physics-code-check/errors.txt
PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx:303:24: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx:1245:24: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGEM/Dilepton/Tasks/matchingMFT.cxx:216:24: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGEM/Dilepton/Utils/ElectronModule.h:390:24: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGEM/Dilepton/Utils/ElectronModule.h:415:24: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
++ [[ 1020 -gt 0 ]]
++ cat /sw/BUILD/6aa877c35271b694a434df60339b7cc39d2ae59c/O2Physics-code-check/warnings.txt
PWGEM/Dilepton/Core/DielectronCut.h:485:8: warning: function 'DielectronCut::SetMindEtadPhi' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:78:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:101:8: warning: constructor does not initialize these fields: ccdb, mRunNumber, d_bz [cppcoreguidelines-pro-type-member-init]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:326:20: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:354:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:355:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:371:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:372:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:388:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:389:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:406:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:407:7: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:463:39: warning: use nullptr [modernize-use-nullptr]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:464:43: warning: use nullptr [modernize-use-nullptr]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:465:24: warning: statement should be inside braces [readability-braces-around-statements]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:501:15: warning: use nullptr [modernize-use-nullptr]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:510:22: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:728:9: warning: if with identical then and else branches [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:758:105: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:857:9: warning: if with identical then and else branches [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:891:105: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1035:13: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1041:13: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1137:24: warning: boolean expression can be simplified by DeMorgan's theorem [readability-simplify-boolean-expr]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1164:39: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1364:7: warning: if with identical then and else branches [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1393:105: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGEM/Dilepton/Core/DileptonHadronMPC.h:1414:13: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGEM/Dilepton/Core/DileptonMC.h:82:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
[0 more errors; see full log]

Full log here.

@vkucera
vkucera marked this pull request as draft October 21, 2026 23:27
Fixes C-style, redundant, wrong, and dangerous casts (found by Clang-Tidy and cpplint).

- Remove redundant casts. (`readability-redundant-casting`)
- Remove `const_cast`. (`cppcoreguidelines-pro-type-const-cast`)
- Replace C-style casts with `static_cast`. (`google-readability-casting`, cpplint: `readability/casting`)
- Replace unsafe C-style casts with `dynamic_cast`. (`cppcoreguidelines-pro-type-cstyle-cast`)
- Replace `static_cast` in downcasts with `dynamic_cast`. (`cppcoreguidelines-pro-type-static-cast-downcast`)
- Replace `reinterpret_cast` with `static_cast` or `dynamic_cast`. (`cppcoreguidelines-pro-type-reinterpret-cast`)
- Replace two-step casting through `void*` with `reinterpret_cast`. (`bugprone-casting-through-void`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

photon Photon and neutral meson PAG label pwgem

Development

Successfully merging this pull request may close these issues.

2 participants