Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-24183

Static assert flagged as error in IDE, compiler is fine with it

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • Qt Creator 4.10.2
    • C/C++/Obj-C++ Support
    • None
    • The compiler is MSVC2017
    • Windows

    Description

      Qt flags this static_assert as an error in the editor. The compiler is fine with it, and will only flag it if the constexpr else block is ever reached (which it currently isn't, in my code):

          template <typename TypeOfValue>
          static void PushValue(duk_context* ctx, TypeOfValue value) {
              // Push value onto duktape stack
              if constexpr (std::is_same<TypeOfValue, int>::value) {
                  // Push int
                  duk_push_int(ctx, value);
              } else if constexpr (std::is_same<TypeOfValue, uint32_t>::value) {
                  // Push uint
                  duk_push_uint(ctx, value);
              } else if constexpr (std::is_same<TypeOfValue, double>::value) {
                  // Push double
                  duk_push_number(ctx, value);
              } else if constexpr (std::is_same<TypeOfValue, std::string>::value) {
                  // Push string
                  duk_push_number(ctx, value);
              } else if constexpr (std::is_same<TypeOfValue, void*>::value) {
                  // Push pointer
                  duk_push_pointer(ctx, value);
              } else {
                  // Unsupported value type
                  static_assert(false, "Unsupported value type");
              }
          }
      

       

      Attachments

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

        Activity

          People

            kandeler Christian Kandeler
            elling73 elling73
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes