This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81973] Aliased virtual methods are treated as undefined, so the vtable is not generated


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

--- Comment #3 from Lorenzo Pistone <blaffablaffa at gmail dot com> ---
That is not the issue, or maybe I don't understand the suggestion. This program
fails just the same:

        #include <iostream>
        using namespace std;

        struct b{
                int a;
                virtual void f(){
                        cout<<__PRETTY_FUNCTION__<<' '<<a<<endl;
                }
        };

        struct s : b{
        #ifdef VIRT_ALIAS
                virtual void f() __attribute__ ((alias ("_ZN1s7f_aliasEv")));
        #endif
                void g() __attribute__ ((alias ("s_g_alias")));
                void f_alias() __attribute__ ((used)) {
                        cout<<__PRETTY_FUNCTION__<<' '<<a<<endl;
                }
        };

        extern "C"{
        void s_g_alias(s* this_){
                cout<<__PRETTY_FUNCTION__<<' '<<this_->a<<endl;
        }
        }

        int main(){
                s a;
                a.a = 123;
                a.f();
                a.g();
        }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]