[llvm-bugs] [Bug 41364] New: `operator new(size_t, align_val_t)` doesn't work in a module

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 3 14:14:42 PDT 2019


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

            Bug ID: 41364
           Summary: `operator new(size_t, align_val_t)` doesn't work in a
                    module
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: blckcat at inbox.ru
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

I seem to be unable to use `operator new(size_t, align_val_t)` in modules.

When compiling this module

    export module a;
    #include <new>

    export void *foo() {
      return ::operator new(1, std::align_val_t(1));
    }

    export int main() {}

with -pedantic-errors I get following error:

    clang++ -std=c++2a -pedantic-errors -fmodules-ts --precompile -x c++-module
a.cpp -o a.pcm
    error: ISO C++ requires a definition in this translation unit for function
'operator new' because its type does not have linkage
[-Werror,-Wundefined-internal-type]
    a.cpp:7:14: note: used here
        return ::operator new(1, std::align_val_t(1));

Removing -pedantic-errors fixes this error, but I still can't link the module
afterwards:

    clang++ -std=c++2a -fmodules-ts a.pcm
    .../a-cfaf65.o:a.pcm:(.text+0x10): undefined reference to
`_ZnwyW1aESt11align_val_t'
    clang++: error: linker command failed with exit code 1 (use -v to see
invocation)

I'm getting this problem on version 8.0.0 provided by MSYS2 (targeting
x86_64-w64-windows-gnu).
I also tried 9.0.0 (trunk 357358) from gcc.godbolt.org, and was able to
reproduce the first error. (Wasn't able to test the linking on that site.)

-- 
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/20190403/b464a1c0/attachment-0001.html>


More information about the llvm-bugs mailing list