Skip to content

Conversation

@iljah
Copy link

@iljah iljah commented Jan 7, 2026

Prevent

../src/libutil/nar-accessor.cc: In function ”nix::ListNarResult<deep> nix::listNarImpl(SourceAccessor&, const CanonPath&) [with bool deep = true]”:
../src/libutil/nar-accessor.cc:335:1: varoitus: ei-void-tyyppisen funktion loppu saavutettu [-Wreturn-type]
  335 | }
      | ^
../src/libutil/nar-accessor.cc: In function ”nix::ListNarResult<deep> nix::listNarImpl(SourceAccessor&, const CanonPath&) [with bool deep = false]”:
../src/libutil/nar-accessor.cc:335:1: varoitus: ei-void-tyyppisen funktion loppu saavutettu [-Wreturn-type]

Motivation

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Prevent
```
../src/libutil/nar-accessor.cc: In function ”nix::ListNarResult<deep> nix::listNarImpl(SourceAccessor&, const CanonPath&) [with bool deep = true]”:
../src/libutil/nar-accessor.cc:335:1: varoitus: ei-void-tyyppisen funktion loppu saavutettu [-Wreturn-type]
  335 | }
      | ^
../src/libutil/nar-accessor.cc: In function ”nix::ListNarResult<deep> nix::listNarImpl(SourceAccessor&, const CanonPath&) [with bool deep = false]”:
../src/libutil/nar-accessor.cc:335:1: varoitus: ei-void-tyyppisen funktion loppu saavutettu [-Wreturn-type]
```
@iljah iljah requested a review from edolstra as a code owner January 7, 2026 16:53
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

Call unreachable() because the switch is supposed to be exhaustive. The fact that only some compilers give this error and not others makes me wonder if we can fix it with compiler flags too

@iljah iljah changed the title Return value from nix::listNarImpl() Use unreachable in nix::listNarImpl() Jan 8, 2026
@iljah
Copy link
Author

iljah commented Jan 8, 2026

Thanks, switched to unreachable().

@xokdvium
Copy link
Contributor

xokdvium commented Jan 8, 2026

Generally, we prefer nix::unreachable() because it doesn't invoke UB and just fails at runtime unlike std::unreachable. It's also marked [[noreturn]], so it should silence the diagnostic.

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.

4 participants