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

clang-tidy warning about cert-err58-cpp #115

Closed
alpha-X-omega opened this issue Jan 16, 2018 · 10 comments
Closed

clang-tidy warning about cert-err58-cpp #115

alpha-X-omega opened this issue Jan 16, 2018 · 10 comments

Comments

@alpha-X-omega
Copy link

Description

run-clang-tidy-5.0.py is detecting

warning: initialization of '_DOCTEST_ANON_VAR_3' with static storage duration may throw an
exception that cannot be caught [cert-err58-cpp] TEST_CASE("example") {

The macro expansion ended at

note: possibly throwing constructor declared here
TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite,

Extra information

  • doctest version: v42.42.42
  • Operating System: Ubuntu 16.04.3
  • Compiler+version: Clang-5.0

The good news is that doctest satisfies all the other checks :)

@onqtam
Copy link
Member

onqtam commented Feb 6, 2018

Any idea how to suppress this? I cannot use // NOLINT where the macros are defined because that has to be used where they are used. I also don't want to add a try {} catch(...) {} block in the test registration function just because of this...

@alpha-X-omega
Copy link
Author

I passed --line-filter=[{"name": "<absolute_path>/doctest/doctest.h", "lines": [[1, 3048], [3050, 5701]]}]` to clang-tidy :-)

@onqtam
Copy link
Member

onqtam commented Feb 6, 2018

In that case I'll be happy to close this issue :D

@onqtam onqtam closed this as completed Feb 6, 2018
@onqtam onqtam reopened this Feb 6, 2018
@onqtam onqtam closed this as completed Feb 6, 2018
@BrannonKing
Copy link

This is clearly not fixed. CLion complains about it on every test.

@onqtam
Copy link
Member

onqtam commented Aug 28, 2018

@BrannonKing Can you use the workaround that is provided in the issue (with using --line-filter=...)?

I might think about adding noexcept but this is not a priority for now - let me know if you want this issue reopened and something done about it..........

@onqtam
Copy link
Member

onqtam commented Nov 3, 2018

It seems that this is actually solvable precisely by using // NOLINT - as can be seen in this PR:
#159
Feel free to try the dev branch with the fix :)

@Trass3r
Copy link

Trass3r commented Feb 26, 2021

I might think about adding noexcept but this is not a priority for now - let me know if you want this issue reopened and something done about it.

I'd also expect these kind of diagnostics to be resolvable by noexcept/constexpr. That doesn't work?

@onqtam
Copy link
Member

onqtam commented Mar 22, 2021

Back in 2018 noexcept wasn't being used in doctest (I think). Now it is. Just pushed a commit that removes all traces of a bare-bones noexcept and favoring DOCTEST_NOEXCEPT - because of #327.

So yes, we should prefer using DOCTEST_NOEXCEPT to suppressing linter warnings. PRs are welcome!

@serguei-k
Copy link
Contributor

Hi Viktor,
making the following change suppresses this warning:
static const int var = doctest::detail::consume(&var, __VA_ARGS__); // NOLINT(cert-err58-cpp) \

Do you mind if I make a PR for this?

@onqtam
Copy link
Member

onqtam commented Apr 6, 2022

sure!

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

No branches or pull requests

5 participants