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

            Bug ID: 89009
           Summary: Miscompilation (missing function call) with
                    -fvisibility=hidden -fpic -O2 -fno-inline
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sbergman at redhat dot com
  Target Milestone: ---

On Linux x86-64 with at least with GCC 8.2.1 (gcc-8.2.1-6.fc29.x86_64) and
recent trunk towards GCC 9, compiling

> $ cat test.cc
> void f1();
> struct S1 { static void f2(); };
> struct __attribute__ ((visibility("default"))) S2: S1 { static void f2(); };
> struct S3: S1 { static void f2(); };
> struct S4: S3 { static void f2(); };
> void S2::f2() { S1::f2(); }
> void S3::f2() { S1::f2(); }
> void S4::f2() {
>     f1();
>     S3::f2(); // MISSING
> }
> 
> $ g++ -fvisibility=hidden -fpic -O2 -fno-inline -S test.cc

causes the call to S3::f2 to be missing from the code generated for S4::f2:

>         .globl  _ZN2S42f2Ev
>         .hidden _ZN2S42f2Ev
>         .type   _ZN2S42f2Ev, @function
> _ZN2S42f2Ev:
> .LFB2:
>         .cfi_startproc
>         jmp     _Z2f1v@PLT
>         .cfi_endproc
> .LFE2:
>         .size   _ZN2S42f2Ev, .-_ZN2S42f2Ev

Reply via email to