https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63164
--- Comment #10 from Thomas de Bock <tdebock at DRWUK dot com> --- After some searching and testing, I realise this optimization does in fact malfunction from (at least version 17.0.1) clang when used with dlopen and RTLD_LOCAL, though the optimization can be disabled with -fno-assume-unique-vtables. I think at least the possiblity to make use of this optimization should also be present in gcc. I think a good way to go about this would be with the addition of an "assume-unique-vtables" (or similar) compiler flag, enabling the optimization. Curious to hear if this would be an acceptable compromise, in which case I'd be more than happy to submit a PR for it.