qvariant.h:710: warning: C4702: unreachable code
-
So you should show use your testcase where it fails ...
-
You maybe can wrap the return with an else
else if constexpr (std::is_same_v<T, std::monostate>) return QVariant(); else return QVariant(QMetaType::fromType<T>(), std::addressof(value)); -
You maybe can wrap the return with an else
else if constexpr (std::is_same_v<T, std::monostate>) return QVariant(); else return QVariant(QMetaType::fromType<T>(), std::addressof(value));@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
You maybe can wrap the return with an else
else if constexpr (std::is_same_v<T, std::monostate>) return QVariant(); else return QVariant(QMetaType::fromType<T>(), std::addressof(value));I do not want to change the Qt source code! 😲
BTW, since in my project the symbol
Q_QDOCis not defined, theelsebranch is grayed out ... -
So you should show use your testcase where it fails ...
@Christian-Ehrlicher I will repeat what I just wrote:
And that is my problem here because the diagnostic MSVC gives me does not show where in my own code that this is being triggered
If I knew where, I could show you.
-
@Christian-Ehrlicher I will repeat what I just wrote:
And that is my problem here because the diagnostic MSVC gives me does not show where in my own code that this is being triggered
If I knew where, I could show you.
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
If I knew where, I could show you.
That's the life of a developer...
-
I neglected to say that I am building with
std:c++17, if that makes any difference. -
Did you try my proposed change?
-
Did you try my proposed change?
@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
Did you try my proposed change?
No, because I do not want to start hacking the Qt source code.
-
In the meantime, I was able to narrow things down by doing
make cleanand compiling each source file individually. I found one file which makes heavy use ofQVariant, and I was able to disable the warning in that file only. Now I have to run a full build to see if there are other places where the warning is triggered. But since I only get one warning, I think this might be the only place.If that is the case, I will come back and mark the thread as "SOLVED".
-
R Robert Hairgrove has marked this topic as solved
-
In the meantime, I was able to narrow things down by doing
make cleanand compiling each source file individually. I found one file which makes heavy use ofQVariant, and I was able to disable the warning in that file only. Now I have to run a full build to see if there are other places where the warning is triggered. But since I only get one warning, I think this might be the only place.If that is the case, I will come back and mark the thread as "SOLVED".
@Robert-Hairgrove
Isn't your error Wrong C4702 unreachable code in templated early if constexpr returnThis is reduced from the Qt 6.8.3 system header QVariant.
?
And assuming it is, as i understand it it is a MSVC not a Qt issue. For which there appears to be a fix release/patch:
A fix for this issue has been released! Install the most recent release from https://visualstudio.microsoft.com/downloads/. Thank you for providing valuable feedback which has helped improve the product.
That was in answer to someone using
cl /std:c++20 Project1.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35207.1 for x64
-
@Robert-Hairgrove
Isn't your error Wrong C4702 unreachable code in templated early if constexpr returnThis is reduced from the Qt 6.8.3 system header QVariant.
?
And assuming it is, as i understand it it is a MSVC not a Qt issue. For which there appears to be a fix release/patch:
A fix for this issue has been released! Install the most recent release from https://visualstudio.microsoft.com/downloads/. Thank you for providing valuable feedback which has helped improve the product.
That was in answer to someone using
cl /std:c++20 Project1.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35207.1 for x64
This post is deleted! -
@Robert-Hairgrove
Isn't your error Wrong C4702 unreachable code in templated early if constexpr returnThis is reduced from the Qt 6.8.3 system header QVariant.
?
And assuming it is, as i understand it it is a MSVC not a Qt issue. For which there appears to be a fix release/patch:
A fix for this issue has been released! Install the most recent release from https://visualstudio.microsoft.com/downloads/. Thank you for providing valuable feedback which has helped improve the product.
That was in answer to someone using
cl /std:c++20 Project1.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35207.1 for x64
@JonB Thanks for the feedback. It is exactly like the first link, which was reported in October 2025 after the fix for the other issue appeared in March 2025.
The two issues are not related. The later issue, which is what I have, is still under investigation.
-
@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
Did you try my proposed change?
No, because I do not want to start hacking the Qt source code.
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
No, because I do not want to start hacking the Qt source code.
This is stupid - you should not hack the source code but just try it out so we can change the code if it works.
So you have to life with the hack - but stop complaining about Qt not fixing your stuff. -
@JonB Thanks for the feedback. It is exactly like the first link, which was reported in October 2025 after the fix for the other issue appeared in March 2025.
The two issues are not related. The later issue, which is what I have, is still under investigation.
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
The later issue, which is what I have, is still under investigation.
OIC :(
-
@Robert-Hairgrove
Isn't your error Wrong C4702 unreachable code in templated early if constexpr returnThis is reduced from the Qt 6.8.3 system header QVariant.
?
And assuming it is, as i understand it it is a MSVC not a Qt issue. For which there appears to be a fix release/patch:
A fix for this issue has been released! Install the most recent release from https://visualstudio.microsoft.com/downloads/. Thank you for providing valuable feedback which has helped improve the product.
That was in answer to someone using
cl /std:c++20 Project1.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35207.1 for x64
@JonB said in qvariant.h:710: warning: C4702: unreachable code:
Isn't your error Wrong C4702 unreachable code in templated early if constexpr return
This is reduced from the Qt 6.8.3 system header QVariant.?
And assuming it is, as i understand it it is a MSVC not a Qt issue. For which there appears to be a fix release/patch:
Yes, it is fixed in the current MSVC version. Thx for the investigation.
-
@JonB said in qvariant.h:710: warning: C4702: unreachable code:
Isn't your error Wrong C4702 unreachable code in templated early if constexpr return
This is reduced from the Qt 6.8.3 system header QVariant.?
And assuming it is, as i understand it it is a MSVC not a Qt issue. For which there appears to be a fix release/patch:
Yes, it is fixed in the current MSVC version. Thx for the investigation.
@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
Yes, it is fixed in the current MSVC version.
Which one? It still happens in the ones I quoted above which I use (MSVC 2022 and MSVC 2026, both Community versions). They are both very recent, although I might have missed an update.
Reading the links that @JonB posted, it is the "internal compiler error" which was fixed in March, 2025. The OTHER link, which was reported in October of 2025, is newer, and there is no mention of a fix.
-
@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
Yes, it is fixed in the current MSVC version.
Which one? It still happens in the ones I quoted above which I use (MSVC 2022 and MSVC 2026, both Community versions). They are both very recent, although I might have missed an update.
Reading the links that @JonB posted, it is the "internal compiler error" which was fixed in March, 2025. The OTHER link, which was reported in October of 2025, is newer, and there is no mention of a fix.
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
Which one?
The latest - 17.14.26 with cl.exe version 19.44.35222 which was released four days ago right after the fix was added (according the link it was fixed at Jan 30, 2026
-
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
Which one?
The latest - 17.14.26 with cl.exe version 19.44.35222 which was released four days ago right after the fix was added (according the link it was fixed at Jan 30, 2026
@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
Which one?
The latest - 17.14.26 with cl.exe version 19.44.35222 which was released four days ago right after the fix was added (according the link it was fixed at Jan 30, 2026
OK, now this is useful information. I am one update behind, it looks like.
I hope you realize, of course, that hacking into the source of
qvariant.hwould have been totally useless (and indeed stupid, IMHO)? -
@Christian-Ehrlicher said in qvariant.h:710: warning: C4702: unreachable code:
@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
Which one?
The latest - 17.14.26 with cl.exe version 19.44.35222 which was released four days ago right after the fix was added (according the link it was fixed at Jan 30, 2026
OK, now this is useful information. I am one update behind, it looks like.
I hope you realize, of course, that hacking into the source of
qvariant.hwould have been totally useless (and indeed stupid, IMHO)?@Robert-Hairgrove said in qvariant.h:710: warning: C4702: unreachable code:
hope you realize, of course, that hacking into the source of qvariant.h would have been totally useless (and indeed stupid, IMHO)?
No - if it would have worked I would created a patch to fix Qt to not hit the compiler error...
-
I'm sorry, but this warning is still there even after I applied the latest MSVC update. ðŸ˜
It does not appear when building with Qt 6.5.3, but it appears with Qt 6.7.3 and (presumably) all later versions up to and including 6.11.0 beta. However, the line numbers of
qvariant.hare different; but the code appears to be exactly the same.Once again, this is with std:c++17.
And with GCC 13.3.0 on Linux, there never was any error. I think the code in
qvariant.his probably correct, and MSVC is wrong.