How to ensure C++ classes don't go missing with -flto?

Jeffrey Walton
Fri Jan 25 01:34:00 GMT 2019

This question on Stack Overflow caught my eye: . In the question a
program compiles and links fine without -flto. With -flto symbols go

One of the classes that go missing is RSAFunction, which performs
exponentiation with a public key. The source code is available at and

There does not seem to be anything special about rsa.h and rsa.cpp
from my view of the issue. The header declares the classes, and then
the source file implements the classes.

How does one ensure a class does not go missing when using -flto?

(Is this like implicit template instantiations? Is there a way to
declare it so that it does not go missing?)

More information about the Gcc-help mailing list