https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112456
Bug ID: 112456 Summary: Diagnostic for [[nodiscard]] on a constructor could be improved Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- struct S { [[nodiscard]] S() { } }; void f() { S(); } This correctly warns: nod.cc: In function 'void f()': nod.cc:7:6: warning: ignoring return value of 'S::S()', declared with attribute 'nodiscard' [-Wunused-result] 7 | S(); | ^ nod.cc:2:17: note: declared here 2 | [[nodiscard]] S() { } | ^ But the text could be improved because a constructor does not have a return value. Maybe "ignoring temporary object constructed by 'S::S()', declared with ...