Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

bugprone-suspicious-semicolon false positive on `if constexpr ()` with template #34797

Closed Quuxplusone closed 4 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR35824
Status RESOLVED FIXED
Importance P normal
Reported by Graham Lustiber (grahamlustiber@gmail.com)
Reported on 2018-01-04 10:20:58 -0800
Last modified on 2019-11-27 11:13:37 -0800
Version unspecified
Hardware Other Linux
CC alexfh@google.com, daphnediane@mac.com, djasper@google.com, grahamlustiber@gmail.com, jvapen@gmail.com, klimek@google.com, marejde@gmail.com, pavel.kryukov@phystech.edu, rianquinn@gmail.com
Fixed by commit(s)
Attachments file_35824.txt (157 bytes, text/plain)
Blocks
Blocked by PR32203
See also
Created attachment 19627
repro file

repro file attached
Quuxplusone commented 6 years ago

Attached file_35824.txt (157 bytes, text/plain): repro file

Quuxplusone commented 6 years ago

I still have this issue on Clang-Tidy 6.0.0

Quuxplusone commented 6 years ago

BTW, the check is now called bugprone-suspicious-semicolon.

Quuxplusone commented 6 years ago

A fix is proposed in https://reviews.llvm.org/D46027 with some questions.

Quuxplusone commented 6 years ago

Appears to be related to 32203 as well.

Quuxplusone commented 6 years ago

Sorry for the inactivity. Feel free to commandeer the patch, I have no idea when can I return to solve this problem.

In the meantime https://reviews.llvm.org/D46233 was merged and https://reviews.llvm.org/D46234 was proposed as an alternative fix.

Quuxplusone commented 5 years ago

Still here in LLVM 8 distribution

Quuxplusone commented 5 years ago

Still/Again there in trunk: https://godbolt.org/z/xNtkWX

Quuxplusone commented 4 years ago
I just ran into this issue with the following code:

    template<typename ERROR = fatal_error, typename... ARGS>
    [[noreturn]] auto
    fatal(ARGS &&... args) -> void
    {
        details::debug::print<0>(
            magenta, "FATAL", std::forward<ARGS>(args)...);

        if constexpr (autosar_compliant) { // <------ triggers false positive
            throw ERROR{};
        }

#ifndef BSL_FATAL_EXIT_INSTEAD_OF_ABORT
        std::abort();    //NOSONAR
#else
        std::exit(1);    //NOSONAR
#endif
    }

It seems that this bug has been in Clang Tidy for come time. Are there any
plans to address this?
Quuxplusone commented 4 years ago

https://reviews.llvm.org/D46027 is still there to work this issue around for more than a year. It comes at the cost of some false negatives. Unfortunately, I do not have time to work on some other solutions. If no one volunteers to pick it up I would suggest to merge https://reviews.llvm.org/D46027.

Quuxplusone commented 4 years ago

Ok, the quick fix should now be committed in https://github.com/llvm/llvm-project/commit/5c5e860535d8924a3d6eb950bb8a4945df01e9b7 .