public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lizekun.zek at bytedance dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/103490] New: Linkage type of typeinfo of polymorphic object with OOL functions
Date: Tue, 30 Nov 2021 09:48:01 +0000	[thread overview]
Message-ID: <bug-103490-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103490

            Bug ID: 103490
           Summary: Linkage type of typeinfo of polymorphic object with
                    OOL functions
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lizekun.zek at bytedance dot com
  Target Milestone: ---

Hi guys,
  I found that the linkage of typeinfo of polymorphic object with OOL-functions
is weak, while that is strong for clang, and I want to attach a patch to make
the behavior of the two compilers consistent. However, I can't find the clear
definition of this in Itanium C++ ABI, so here are the questions:

1.It is easy to understand that we make the object with inlined-functions weak, 
  because it usually appears in a header file and may be defined several times, 
  so when functions are out-of-line, why do we make it weak?

2.In fact, I prefer the gcc way, are there any cases that show gcc is 
  better?

This is a case to show the issue.

---
test.h

class A{
public:
    virtual const int getA(){} ;
    virtual const int getB(){} ;
};

---
testA.cpp

#include<iostream>
#include "test.h"
using namespace std;

class Test : public A {
public:
    virtual const int getA() override;
};
const int Test ::getA() {
    return 1;
}


int main() {
    A * t=new Test();;
    cout << dynamic_cast<Test*>(t);
}
---

testB.cpp

#include "test.h"

class Test : A {
public:
    virtual const int getB() override;
};
const int Test :: getB() {
    return 2;
}

             reply	other threads:[~2021-11-30  9:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  9:48 lizekun.zek at bytedance dot com [this message]
2021-12-20 23:27 ` [Bug c++/103490] " pinskia at gcc dot gnu.org
2021-12-21  0:02 ` pinskia at gcc dot gnu.org
2021-12-22  5:04 ` rjmccall at gmail dot com
2021-12-22  7:07 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103490-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).