Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48516

Q_STATIC_ASSERT_X, MSVC2013 and Q_DECL_CONSTEXPR

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.4.2
    • Core: Other
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            TheBadger Carel Combrink
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes