clang-tidy warnings #584

Closed
opened 2024-11-23 04:36:18 +00:00 by artemist · 1 comment
Member

Describe the bug

When upgrading to clang 18 a large number of new clang-tidy warnings appear. Many are nuisance warnings, but some may be hiding actual errors.

A few that seemed like they might be important:

A large number of places also dereference a std::optional then pass it to a function taking a std::optional. This is undefined behavior if the optional is empty. From tests in compiler explorer, clang and gcc will both silently mark the optional as having a value but leave the memory uninitialized.

Steps To Reproduce

Run clang-tidy, either with just tidy or nix build .#hydraJobs.tests.clang-tidy, after upgrading to nixpkgs 24.11 with clang 18. The warnings are also shown in a buildbot log.

Expected behavior

No warnings appear

nix --version output

N/A

## Describe the bug When upgrading to clang 18 a large number of new clang-tidy warnings appear. Many are nuisance warnings, but some may be hiding actual errors. A few that seemed like they might be important: * https://git.lix.systems/lix-project/lix/src/commit/66f6dbda32959dd5cf3a9aaba15af72d037ab7ff/lix/libstore/nar-accessor.cc#L148 canonicalizes the path then completely ignores its canonicalized path * https://git.lix.systems/lix-project/lix/src/commit/66f6dbda32959dd5cf3a9aaba15af72d037ab7ff/lix/libstore/build/local-derivation-goal.cc#L710 opens a log file then ignores the path * https://git.lix.systems/lix-project/lix/src/commit/66f6dbda32959dd5cf3a9aaba15af72d037ab7ff/lix/nix/search.cc#L163 highlights a name then doesn't do anything with it A large number of places also dereference a `std::optional` then pass it to a function taking a `std::optional`. This is undefined behavior if the optional is empty. From tests in compiler explorer, clang and gcc will both silently mark the optional as having a value but leave the memory uninitialized. ## Steps To Reproduce Run `clang-tidy`, either with `just tidy` or `nix build .#hydraJobs.tests.clang-tidy`, after upgrading to nixpkgs 24.11 with clang 18. The warnings are also shown in [a buildbot log](https://buildbot.lix.systems/api/v2/logs/596703/raw_inline). ## Expected behavior No warnings appear ## `nix --version` output N/A
artemist added the
bug
label 2024-11-23 04:36:18 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/2282 ("tree-wide: fix a pile of lints")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/2282", "number": 2282, "kind": "commit message"}], "cl_meta": {"2282": {"change_title": "tree-wide: fix a pile of lints"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/2282](https://gerrit.lix.systems/c/lix/+/2282) ("tree-wide: fix a pile of lints")
jade referenced this issue from a commit 2024-12-06 01:20:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#584
No description provided.