Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused parameters warning in release mode #90

Closed
killerbot242 opened this issue Jan 27, 2021 · 1 comment
Closed

Unused parameters warning in release mode #90

killerbot242 opened this issue Jan 27, 2021 · 1 comment
Assignees
Labels

Comments

@killerbot242
Copy link

File : cli.h

affected code:

template <typename F> struct Select<F> { template <typename InputIt> static void Exec(const F& f, InputIt first, InputIt last) { assert(first == last); f(); } };
keep in mind that assert turns into void in release builds, either always check and throw exceptions, or ensure that the code can compile when the assert is gone.
In release build (assert turns into void) the arguments first and last are not used, and the compiler warns about that, and in our good practices book warnings turn into errors, and as such our build is broken.

Solutions:
old style:
template <typename F> struct Select<F> { template <typename InputIt> static void Exec(const F& f, InputIt first, InputIt last) { assert(first == last); f(); (void)first;(void)last; <======================== } };

or you can also use c++17 attributes [[maybe_unused]], I would prefer that, but depends what you want as minimum compiler requirements.

kind regards,
Lieven

@daniele77 daniele77 self-assigned this Jan 27, 2021
@daniele77 daniele77 added the bug label Jan 27, 2021
@daniele77 daniele77 changed the title latest code state no longer builds (warning --> error) Unused parameters warning in release mode Jan 27, 2021
@daniele77
Copy link
Owner

@killerbot242 thank you very much for opening this issue. I solved it with the cast because the library targets C++14, so that we can't use the [[maybe_unused]] available in C++17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants