[llvm-bugs] [Bug 51558] New: Address of dllimport symbol is not constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 20 06:43:32 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51558

            Bug ID: 51558
           Summary: Address of dllimport symbol is not constexpr
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: skyostil at chromium.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following C++ program fails to compile on the x64_64-pc-windows-msvc
target:

  extern __declspec(dllimport) int x;
  constexpr int* y = &x;

Error message:

  test.cc(7,16): error: constexpr variable 'y' must be initialized by a
constant expression

This is on Clang version 14.0.0 (https://github.com/llvm/llvm-project/
ee65938357d5fffe9e586fa155b37268b5a358ac), target: x86_64-pc-windows-msvc. I
ran into this while trying to compile Perfetto (https://perfetto.dev) as a part
of Chromium.

The same program builds correctly on MSVC (tested on 19.29.30037 for x64).
Interestingly, MSVC had a regression related to this in 2018[1] which has since
been fixed.

[1]
https://developercommunity.visualstudio.com/t/c-regression-stdmax-of-two-constexpr-does-not-eval/312456

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210820/672332f4/attachment.html>


More information about the llvm-bugs mailing list