[llvm-bugs] [Bug 45322] New: clang -O2 doesn't export the same symbols as gcc with virtual destructor

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 26 16:13:51 PDT 2020


            Bug ID: 45322
           Summary: clang -O2 doesn't export the same symbols as gcc with
                    virtual destructor
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: sylvestre at debian.org
                CC: llvm-bugs at lists.llvm.org

Happening on a bunch of cases here:

Probably not a recent issue

=== a.cpp ===
#include <stddef.h>
namespace pugi {
class xml_writer {
  virtual ~xml_writer() {}
class a : xml_writer {
  virtual void b(const void *, size_t);
void a::b(const void *, size_t) {}
} // namespace pugi

=== script

ARG="  -O2 -o pugixml.cpp.o -c a.cpp"

mv pugixml.cpp.o clang.o

mv pugixml.cpp.o gcc.o

nm clang.o |grep -q N4pugi10xml_writerD2Ev
nm gcc.o |grep -q  N4pugi10xml_writerD2Ev

Will show:

nm clang.o |grep N4pugi10xml_writerD2Ev
0000000000000000 W _ZN4pugi10xml_writerD2Ev
nm gcc.o |grep  N4pugi10xml_writerD2Ev

without -O2, gcc will generate the symbol too.

maybe clang should remove too when -O2 is used?

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/20200326/1d345004/attachment.html>

More information about the llvm-bugs mailing list