For reference, here is an explanation of the problem that led me to this solution: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60464