https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84476
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Martin Ankerl from comment #1) > I just "discovered" this bug as well. The warning works correctly in g++ > 6.4, but starting from 7.1 upwards it does not work any more. No, I don't think that's true, this never worked. The warning for gcc 6 is telling you that it doesn't understand the [[nodiscard]] attribute. You would get the same warning for [[lolwut]]. GCC 7 does understand the attribute, so that -Wattributes warning is gone, but the expected warning about the unused result is missing.