bebuch
u/bebuch
How is the else notation different? If you argue that the code is unreachable in that particular instantiation, you can say the same about any code in the else branch.
Of course no one would say that, because it's the point of an if-else that only one branch is evaluated, even on a template dependent constexpr compile time evaluation.
And its the exact same thing with an early return in a constexpr if. For the same reason you won't warn that the else branch is not evaluated for that instantiation, you must not warn about code after an early return.
That you can workaround that with the else notation doesn't make this a valid warning.
However, would you be so kind to forward this to the compiler team? I'm waiting on feedback for over a month now and in my experience that means that it got stuck in some pre-review and was forgotten there. 😅
Could you please have a look at my MSVC bug report:
https://developercommunity.visualstudio.com/t/Wrong-C4702-unreachable-code-in-template/10978308
I didn't test yet if it can be reproduced with VS 2026. But it would be helpful to get some feedback.