https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79819
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- You can create additional attachments one at a time. Yes, I believe your code has undefined behaviour, so the linker error is not a gcc bug.