https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119518
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So the original code for this was added with r0-49393-gb2dd096b0c7e5c. If the definition of foo was after the use at the time the GCC would emit the S::~S call (unless you compiled with -funit-at-a-time which was enabled for -O2 and above). But starting in GCC 4.0 (with ssa), it didn't matter if the definition of foo was after or not since we would gimplify/genericify the function and get the setting even for definitions afterwards.