Fix -Wmissing-field-initializers on Clang 18 #543

Open
opened 2024-10-09 20:43:27 +00:00 by jade · 4 comments
Owner

Currently on main we build with Clang 17. It appears that Clang 18 added a giant pile of field initializer warnings. I am thus disabling the warning for the time being until those warnings get dealt with. This, however, should be actually fixed.

If you want to help fix this, you can temporarily change the version of clang to 18 by changing the flake to use clang18Stdenv or by temporarily updating the flake to nixpkgs unstable and you will get the warnings.

lix> ../src/libutil/error.hh:120:64: warning: missing field 'pos' initializer [-Wmissing-field-initializers]
lix>   120 |         : err { .level = lvlError, .msg = HintFmt(fs, args...) }
lix>       |                                                                ^
lix> ../src/libexpr/eval-error.hh:33:11: note: in instantiation of function template specialization 'nix::BaseError::BaseError<const char *, const char *>' requested here
lix>    33 |         : Error(formatString, formatArgs...)
lix>       |           ^
lix> ../src/libexpr/eval-error.hh:75:17: note: in instantiation of function template specialization 'nix::EvalError::EvalError<const char *, const char *>' requested here
lix>    75 |         : error(T(state, args...))
lix>       |                 ^
lix> ../src/libexpr/eval.hh:236:21: note: in instantiation of function template specialization 'nix::EvalErrorBuilder<nix::EvalError>::EvalErrorBuilder<char[73], const char *, const char *>' requested here
lix>   236 |         return *new EvalErrorBuilder<T>(*this, args...);
lix>       |                     ^
lix> ../src/libexpr/eval.cc:2231:9: note: in instantiation of function template specialization 'nix::EvalState::error<nix::EvalError, char[73], const char *, const char *>' requested here
lix>  2231 |         error<EvalError>("the string '%1%' is not allowed to refer to a store path (such as '%2%')", v.string.s, v.string.context[0]).withTrace(pos, errorCtx).debugThrow();
lix>       |         ^
lix> In file included from ../src/libexpr/eval.cc:1:
lix> In file included from ../src/libexpr/eval.hh:4:
lix> In file included from ../src/libexpr/attr-set.hh:4:
lix> In file included from ../src/libexpr/nixexpr.hh:7:
lix> In file included from ../src/libexpr/value.hh:12:
lix> In file included from ../src/libexpr/value/context.hh:5:
lix> In file included from ../src/libstore/derived-path.hh:4:
lix> In file included from ../src/libutil/config.hh:11:
lix> In file included from ../src/libutil/experimental-features.hh:4:
Currently on main we build with Clang 17. It appears that Clang 18 added a giant pile of field initializer warnings. I am thus disabling the warning for the time being until those warnings get dealt with. This, however, should be actually fixed. If you want to help fix this, you can temporarily change the version of clang to 18 by changing the flake to use clang18Stdenv or by temporarily updating the flake to nixpkgs unstable and you will get the warnings. ``` lix> ../src/libutil/error.hh:120:64: warning: missing field 'pos' initializer [-Wmissing-field-initializers] lix> 120 | : err { .level = lvlError, .msg = HintFmt(fs, args...) } lix> | ^ lix> ../src/libexpr/eval-error.hh:33:11: note: in instantiation of function template specialization 'nix::BaseError::BaseError<const char *, const char *>' requested here lix> 33 | : Error(formatString, formatArgs...) lix> | ^ lix> ../src/libexpr/eval-error.hh:75:17: note: in instantiation of function template specialization 'nix::EvalError::EvalError<const char *, const char *>' requested here lix> 75 | : error(T(state, args...)) lix> | ^ lix> ../src/libexpr/eval.hh:236:21: note: in instantiation of function template specialization 'nix::EvalErrorBuilder<nix::EvalError>::EvalErrorBuilder<char[73], const char *, const char *>' requested here lix> 236 | return *new EvalErrorBuilder<T>(*this, args...); lix> | ^ lix> ../src/libexpr/eval.cc:2231:9: note: in instantiation of function template specialization 'nix::EvalState::error<nix::EvalError, char[73], const char *, const char *>' requested here lix> 2231 | error<EvalError>("the string '%1%' is not allowed to refer to a store path (such as '%2%')", v.string.s, v.string.context[0]).withTrace(pos, errorCtx).debugThrow(); lix> | ^ lix> In file included from ../src/libexpr/eval.cc:1: lix> In file included from ../src/libexpr/eval.hh:4: lix> In file included from ../src/libexpr/attr-set.hh:4: lix> In file included from ../src/libexpr/nixexpr.hh:7: lix> In file included from ../src/libexpr/value.hh:12: lix> In file included from ../src/libexpr/value/context.hh:5: lix> In file included from ../src/libstore/derived-path.hh:4: lix> In file included from ../src/libutil/config.hh:11: lix> In file included from ../src/libutil/experimental-features.hh:4: ```
jade added the
devx
E/easy
E/help wanted
labels 2024-10-09 20:43:27 +00:00

I'm happy to pick up the task of fixing the field initializer warnings. I already handled a bunch of them in this commit = cl/2044.

I'm happy to pick up the task of fixing the field initializer warnings. I already handled a bunch of them in [this commit](https://git.lix.systems/lix-project/lix/commit/43e79f443469c55ef4d3a43ce1e455d6eafcd26c) = cl/2044.
jade self-assigned this 2024-10-09 21:31:06 +00:00
Author
Owner

oh, i actually have got on fixing a lot of these.

oh, i actually have got on fixing a lot of these.

Cool :) Just go ahead. I have other things to work on.

Cool :) Just go ahead. I have other things to work on.
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/2054 ("tree-wide: fix missing field initializers found by Clang 18")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/2054", "number": 2054, "kind": "commit message"}], "cl_meta": {"2054": {"change_title": "tree-wide: fix missing field initializers found by Clang 18"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/2054](https://gerrit.lix.systems/c/lix/+/2054) ("tree-wide: fix missing field initializers found by Clang 18")
Sign in to join this conversation.
No milestone
No project
No assignees
3 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#543
No description provided.