qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.48k stars 3.99k forks source link

Use proper macro for unreachable switch cases #21752

Closed Chocobo1 closed 2 weeks ago

Chocobo1 commented 2 weeks ago

Those are the default cases which are not expected to hit (nor reachable) normally.

When the code is compiled with release mode and it reaches Q_UNREACHABLE(), it becomes undefined behavior. So it rely on the developers to catch the errors in debug mode. The upside of this is that the switch statement will be more optimized than not using it. This also means the statements after Q_UNREACHABLE() isn't important. It allow anything to preserve the intention of the code.

This marco is preferred over C++23 std::unreachable because it will automatically insert a Q_ASSERT(false) with it.

qBittUser commented 2 weeks ago

Is marco a typo, that's currently written in PR & commit titles + opening post & commit info?

Isn't the correct word macro?

kimo15x commented 2 weeks ago

thanks.