[llvm-bugs] [Bug 43280] New: Static constexpr string struct causes unresolved symbols on Windows

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 11 09:44:19 PDT 2019


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

            Bug ID: 43280
           Summary: Static constexpr string struct causes unresolved
                    symbols on Windows
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ToHe_EMA at gmx.de
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

We are currently exploring to compile our software on Windows with Clang, but
hit a couple Clang/LLVM bugs along the way. Using a static constexpr string in
a struct/class results in unresolved symbols when linking. The minimal code
needed to trigger the bug looks like this:
struct Struct
{
        static constexpr char const* ConstexprVar = "Test";
        char const* const* Do() { return &ConstexprVar; }
};
int main() { Struct().Do(); }

It is simply compiled with "clang++ Main.cpp" without further options which
then results in this error:
>Main-70a406.o : error LNK2019: unresolved external symbol "public: static char const * const Struct::ConstexprVar" >(?ConstexprVar at Struct@@2QEBDEB) referenced in
> function "public: char const * const * __cdecl Struct::Do(void)" (?Do at Struct@@QEAAPEBQEBDXZ)
>Main.o : fatal error LNK1120: 1 unresolved externals
>clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

When trying to link with lld, the result is the same:
>lld: error: undefined symbol: public: static char const *const Struct::ConstexprVar
>>> referenced by Main.o:(public: char const *const * __cdecl Struct::Do(void))

At least the current stable release 8.0 and the nightly build (from here
https://llvm.org/builds/) are affected.

-- 
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/20190911/a4472b5d/attachment.html>


More information about the llvm-bugs mailing list