https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70782
Josh Haberman <jhaberman at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|zero-initialized union |zero-initialized long |returned by value generates |returned by value generates |useless stores/loads to the |useless stores/loads to the |stack |stack --- Comment #1 from Josh Haberman <jhaberman at gmail dot com> --- I just realized that the union has nothing to do with it. I get exactly the same results if the function returns a long: -- #include <string.h> long f(const void *p, int type) { long v; memset(&v, 0, 8); if (type == 1) { memcpy(&v, p, 1); } else if (type <= 5) { memcpy(&v, p, 4); } else if (type <= 8) { memcpy(&v, p, 8); } return v; } -- I've retitled the bug accordingly.