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

Compilation error on MSVC with enabled constexpr on 32-bit target

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.9.7, 5.11.2
    • 5.10.1
    • None
    • Visual Studio 2017 Update 6, x86 target platform
    • 8dd78e8564d8c4249e85653a8119c1dd1a03d659 c59cb9809559f0aae6be8544cb2049e41f8040e9

      Consider the following code:

      #define __cpp_constexpr 201304
      #include <qalgorithms.h>
      

      The code fails when compiled with Visual Studio 2017 Update 6 (C++17 mode) for x86 platform:

      >cl main.cpp -IC:\Qt\5.10.1\msvc2017_64\include\QtCore -IC:\Qt\5.10.1\msvc2017_64\include -std:c++17
      Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26129 for x86
      Copyright (C) Microsoft Corporation.  All rights reserved.
      
      main.cpp
      C:\Qt\5.10.1\msvc2017_64\include\QtCore\qalgorithms.h(847): error C3615: constexpr function 'qCountLeadingZeroBits' cannot result in a constant expression
      C:\Qt\5.10.1\msvc2017_64\include\QtCore\qalgorithms.h(858): note: failure was caused by call of undefined function or one not declared 'constexpr'
      C:\Qt\5.10.1\msvc2017_64\include\QtCore\qalgorithms.h(858): note: see usage of 'qPopulationCount'
      

      The code compiles fine for x64 target.

      The issue seemingly comes from using non-constexpr intrinsics like _BitScanReverse in functions marked with constexpr.

        For Gerrit Dashboard: QTBUG-67259
        # Subject Branch Project Status CR V

            thiago Thiago Macieira
            mwu Michał Urbańczyk
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes