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

--- Comment #7 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Looks like original test does not trigger the bug as is (probably due to tets
fragility). Here is something shorter (but with warnings):

```c++
struct a {
  char at;
  char au;
  int d() { return av() + au - at; }
  virtual void f() {}
  virtual int av() { }
};
struct g : a {
  void f();
  char b;
  char c() { return b; }
} b;
#ifdef MAIN_FILE
g e;
void h() {
  if (b.c()) {
    e.d();
    return;
  }
}
int main() {}
#endif
#ifdef LIB_FILE
void g::f() {}
#endif
```

$ g++-11.0.0 -Wall -fPIC -O1 -fdevirtualize -fdevirtualize-speculatively
-fipa-cp -fipa-cp-clone -fvisibility-inlines-hidden -fPIC -shared -o libbug.so
bug.cpp -DLIB_FILE
bug.cpp: In member function 'virtual int a::av()':
bug.cpp:6:22: warning: no return statement in function returning non-void
[-Wreturn-type]
    6 |   virtual int av() { }
      |                      ^

$ g++-11.0.0 -Wall -fPIC -O1 -fdevirtualize -fdevirtualize-speculatively
-fipa-cp -fipa-cp-clone -fvisibility-inlines-hidden -o main bug.cpp -DMAIN_FILE
-L. -lbug
bug.cpp: In member function 'virtual int a::av()':
bug.cpp:6:22: warning: no return statement in function returning non-void
[-Wreturn-type]
    6 |   virtual int av() { }
      |                      ^
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../x86_64-pc-linux-gnu/bin/ld:
/tmp/ccbaHYef.o: in function `h()':
bug.cpp:(.text+0x1a): undefined reference to `a::av()'
collect2: error: ld returned 1 exit status

Reply via email to