Skip to content

fix(LibCarla): eliminate compiler warnings#9587

Open
youtalk wants to merge 5 commits intocarla-simulator:ue5-devfrom
youtalk:fix/libcarla-compiler-warnings
Open

fix(LibCarla): eliminate compiler warnings#9587
youtalk wants to merge 5 commits intocarla-simulator:ue5-devfrom
youtalk:fix/libcarla-compiler-warnings

Conversation

@youtalk
Copy link

@youtalk youtalk commented Mar 12, 2026

Description

Eliminate compiler warnings across LibCarla to achieve clean builds.

Based on ue4-dev commit d179041, this PR fixes compiler warnings across 20 files including:

  • Unnecessary deep copies in range-for loops (auto constconst auto&)
  • Pessimizing moves preventing NRVO
  • Signed/unsigned implicit conversions
  • Double-to-float narrowing conversions
  • C-style casts replaced with static_cast/reinterpret_cast
  • Unused parameter annotations (/*name*/)
  • Unused variables and lambda captures removed
  • Third-party header fixes (namespace pollution, bitfield sign, duplicate macros)

Files skipped (already fixed or N/A in ue5-dev):

  • FIleTransfer.cpp — Renamed to FileTransfer.cpp and rewritten with std::filesystem
  • GeoReferenceParser.cpp — Completely different implementation
  • GeometryParser.cpp, RoadParser.cpp — Already fixed
  • ALSM.cpp, LocalizationStage.cpplarge_vehicles member doesn't exist
  • test_geom.cpp — Quaternion test doesn't exist

Fixes #9583 (partial — PR #0d)

Where has this been tested?

  • Platform(s): Linux (Ubuntu 24.04)
  • Python version(s): 3.12
  • Unreal Engine version(s): 5.5

Possible Drawbacks

Pure code quality improvements with no behavioral changes. Some third-party header fixes may need to be re-applied if those headers are regenerated.


This change is Reviewable

- Fix deep copies in range-for loops (auto const → const auto&)
- Remove pessimizing std::move() on return statements
- Fix signed/unsigned implicit conversions with size_t/static_cast
- Add static_cast for double-to-float narrowing
- Replace C-style casts with static_cast/reinterpret_cast
- Annotate unused parameters with /*name*/ comment syntax
- Fix misleading indentation
- Remove unused variables and lambda captures
- Fix third-party headers (namespace pollution, bitfield sign, duplicate macros)

Reference: ue4-dev commit d179041
@update-docs
Copy link

update-docs bot commented Mar 12, 2026

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

@youtalk youtalk marked this pull request as ready for review March 12, 2026 05:12
@youtalk youtalk requested a review from a team as a code owner March 12, 2026 05:12
Copilot AI review requested due to automatic review settings March 12, 2026 05:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Eliminates compiler warnings across LibCarla (and some bundled third-party headers) to achieve cleaner builds, primarily by fixing signed/unsigned conversions, narrowing conversions, unnecessary moves/copies, and C-style casts.

Changes:

  • Replaces C-style casts with static_cast/reinterpret_cast, and addresses narrowing + signed/unsigned conversion warnings in core and test code.
  • Cleans up third-party headers (namespace pollution, duplicate macros, bitfield signedness) and adjusts indexing to use size_t where applicable.
  • Removes/annotates unused parameters, variables, and lambda parameters to silence warnings.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
LibCarla/source/third-party/simplify/Simplify.h Cleans up macros/casts/indexing and removes duplicated macro definition to reduce warnings.
LibCarla/source/third-party/marchingcube/Triangulation.h Adds size_t casts for safe indexing into edgeVertIndices.
LibCarla/source/third-party/marchingcube/MeshReconstruction.h Removes using namespace pollution and re-scopes definitions into MeshReconstruction.
LibCarla/source/third-party/marchingcube/Cube.h Fixes bitfield signedness and loop index type to remove warnings.
LibCarla/source/test/server/test_benchmark_streaming.cpp Replaces C-style cast with static_cast for std::max.
LibCarla/source/test/client/test_opendrive.cpp Fixes double-to-float narrowing warning in timing code.
LibCarla/source/test/client/test_image.cpp Fixes implicit int-to-float conversion in depth reconstruction.
LibCarla/source/carla/road/element/Geometry.cpp Fixes integer-to-double division warning in delta_p computation.
LibCarla/source/carla/road/MeshFactory.cpp Fixes signed/unsigned and narrowing conversions for mesh generation and UVs.
LibCarla/source/carla/road/MapBuilder.cpp Fixes narrowing conversions and signed multiplication in transforms/positions.
LibCarla/source/carla/road/Map.cpp Removes pessimizing moves, fixes indexing types, and silences unused parameter/variable warnings.
LibCarla/source/carla/road/Deformation.h Fixes narrowing conversions and float/double literal mismatches.
LibCarla/source/carla/multigpu/secondary.cpp Silences unused lambda param warnings and fixes size cast warnings.
LibCarla/source/carla/multigpu/router.cpp Replaces C-style casts with reinterpret_cast for buffer header creation.
LibCarla/source/carla/multigpu/primaryCommands.cpp Replaces C-style casts with reinterpret_cast/const_cast for buffer creation and removes unused response variables.
LibCarla/source/carla/multigpu/primary.cpp Silences unused lambda param warnings and fixes size cast warnings.
LibCarla/source/carla/geom/Simplification.cpp Fixes implicit float-to-int conversion for simplify_mesh argument.
LibCarla/source/carla/geom/Mesh.cpp Fixes signed/unsigned warnings around vertex-link indexing calculations.
LibCarla/source/carla/client/detail/Simulator.cpp Fixes signed/unsigned and underflow risk when iterating backwards over a string.
LibCarla/source/carla/Exception.h Silences unused source_location parameter warning.
CHANGELOG.md Documents the warning cleanup change at a high level.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JesusAnaya
Copy link

Thank you, @youtalk, for the code review. I will try to resolve these issues as soon as possible.

@jorge-kabuto jorge-kabuto self-assigned this Mar 13, 2026
@youtalk
Copy link
Author

youtalk commented Mar 13, 2026

@JesusAnaya @jorge-kabuto Since the purpose of these PRs ware to simply port from ue4-dev, I was thinking of keeping the scope of changes to a minimum. Should I make the fixes suggested in Copilot’s review? I can do them if necessary.

@JesusAnaya
Copy link

@youtalk I made some comments and suggestions. 👋

youtalk and others added 3 commits March 20, 2026 09:15
Co-authored-by: Jesus Armando Anaya <jesus@armandoanaya.com>
Co-authored-by: Jesus Armando Anaya <jesus@armandoanaya.com>
Co-authored-by: Jesus Armando Anaya <jesus@armandoanaya.com>
@youtalk youtalk requested a review from JesusAnaya March 20, 2026 16:16
@youtalk
Copy link
Author

youtalk commented Mar 20, 2026

@JesusAnaya Thank you for your review. I've reflected all of them. Please do it again and approve if it's okay.

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.

Port ue4-dev features and fixes to ue5-dev

4 participants