https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90895
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Of course, if the code is optimized then no warnigns are issued at all, because b.f() and b2.g() get inlined to nothing, and so no calls to the functions remain.