Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.4.2
-
None
-
Windows 7
MSVC 2013 Update 5
Qt 5.4.2
Description
I have defined a function as (this is not my real function):
Q_DECL_CONSTEXPR int myFunction(int x) { return (x == 0)? 0 : myFunction(x - 1); }
Then I have a call:
Q_STATIC_ASSERT_X(myFunction(16) == 1, "Not valid");
I get the following compiler error:
error: C2057: expected constant expression
Further investigation reveals that Q_DECL_CONSTEXPR is empty on MSVC2013 since MSVC2013 does not support constexpr (https://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx)
resulting in Q_COMPILER_CONSTEXPR not being defined.
All of this makes sense, but I would then expect Q_STATIC_ASSERT_X to also know that this is not supported, thus attempt to work around this, perhaps by reverting back to "the compiler does not have static assert" and use the else in "qglobal.h"
PS: I have looked at qglobal.h in the upcoming Qt5.6 and it also does not seem to handle this differently.