Re: C++20 modules: exporting classes with virtual destructors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



FWIIW, this case does compile with Clang12:

/opt/llvm-12/bin/clang++ task.cpp -std=c++20 -c -o task.pcm -Xclang
-emit-module-interface
/opt/llvm-12/bin/clang++ task.cpp -std=c++20 -c -o task.o
-fprebuilt-module-path=.
/opt/llvm-12/bin/clang++ main.cpp -std=c++20 -c -o main.o
-fprebuilt-module-path=.

On Mon, Nov 29, 2021 at 4:08 PM Oleg Smolsky <osmolsky@xxxxxxxxxxxx> wrote:

> Hi there! I'm trying to integrate C++20 modules into my project and got
> stuck on a "virtual destructor" issue. Here is a minimal reproducer
> rejected by GCC11:
>
> /opt/gcc-11/bin/g++ -std=c++20 -fmodules-ts -c -o main.o main.cpp
> main.cpp: In function ‘int main()’:
> main.cpp:6:12: error: invalid use of non-static member function ‘virtual
> Derived@task::~Derived()’
>     6 |     delete p;
>
> The module is called "task" and here is its interface (task.cpp):
>
>     export module task;
>     #include "b.h"
>     #include "d.h"
>
> b.h:
>
>     #pragma once
>     export struct Base {
>       virtual ~Base() = default;
>       void DoStuff();
>     };
>
> b.cpp:
>
>     module;
>     #include <string>
>     module task;
>     void Base::DoStuff() {}
>
> The consumer is exactly what you'd imagine - "new Derived;", followed by a
> virtual call, followed by the "delete".
>
> How is this supposed to work? Is this code Standard-compliant?
>
> Thanks!
> Oleg.
>




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux