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] -Wunreachable-code does not work on macros #116296

Open
tiagomacarios opened this issue Nov 14, 2024 · 0 comments
Open

[clang] -Wunreachable-code does not work on macros #116296

tiagomacarios opened this issue Nov 14, 2024 · 0 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative

Comments

@tiagomacarios
Copy link
Contributor

For the code below clang should emit 2 unreachable code warnings, but it only emits one

https://godbolt.org/z/fT9rs5xYn

#include <type_traits>

[[noreturn]] void crash() noexcept;

#define VerifyElseCrash(b) \
    if (!b) [[unlikely]] { \
        crash();           \
    }

void some_other_funtion();

int f1() {
    if (!false) [[unlikely]] {
        crash();
    }

    some_other_funtion(); // dead code
}

int f2() {
    VerifyElseCrash(false);

    some_other_funtion(); // dead code
}
@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 14, 2024
@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative and removed clang Clang issues not falling into any other category labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative
Projects
None yet
Development

No branches or pull requests

2 participants