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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.10.1
    • Fix Version/s: 5.9.7, 5.11.2
    • Labels:
      None
    • Environment:
      Visual Studio 2017 Update 6, x86 target platform
    • Commits:
      8dd78e8564d8c4249e85653a8119c1dd1a03d659 c59cb9809559f0aae6be8544cb2049e41f8040e9

      Description

      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.

        Attachments

          Issue Links

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

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes