public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/105130] New: gcc does not warn about unused return value of last expression of statement expr @ 2022-04-01 19:55 dani at danielbertalan dot dev 2022-04-01 20:14 ` [Bug c++/105130] " dani at danielbertalan dot dev ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: dani at danielbertalan dot dev @ 2022-04-01 19:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105130 Bug ID: 105130 Summary: gcc does not warn about unused return value of last expression of statement expr Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dani at danielbertalan dot dev Target Milestone: --- Created attachment 52739 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52739&action=edit Proposed patch The following code does not cause a warning about the return value of the foo() function being ignored: $ cat unused.cc [[nodiscard]] int foo(); int main() { ({ foo(); }); } $ g++ -Wunused-value -std=c++20 unused.cc [no warnings] The issue seems to be that CLEANUP_POINT_EXPR and STATEMENT_LIST -- which are what statement expressions are turned into -- are not handled in convert_to_void() (cp/cvt.cc). The attached patch resolves the issue, but as a newbie to hacking on gcc, I can't evaluate if it has any unintended consequences. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/105130] gcc does not warn about unused return value of last expression of statement expr 2022-04-01 19:55 [Bug c++/105130] New: gcc does not warn about unused return value of last expression of statement expr dani at danielbertalan dot dev @ 2022-04-01 20:14 ` dani at danielbertalan dot dev 2022-04-09 6:37 ` egallager at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: dani at danielbertalan dot dev @ 2022-04-01 20:14 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105130 --- Comment #1 from Daniel Bertalan <dani at danielbertalan dot dev> --- Created attachment 52740 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52740&action=edit Proposed patch #2 Actually, my proposed patch was definitely incorrect. It didn't allow me to circumvent the warning by explicitly casting to void. This new version fixes that issue. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/105130] gcc does not warn about unused return value of last expression of statement expr 2022-04-01 19:55 [Bug c++/105130] New: gcc does not warn about unused return value of last expression of statement expr dani at danielbertalan dot dev 2022-04-01 20:14 ` [Bug c++/105130] " dani at danielbertalan dot dev @ 2022-04-09 6:37 ` egallager at gcc dot gnu.org 2022-11-28 18:25 ` pinskia at gcc dot gnu.org 2022-11-28 18:30 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: egallager at gcc dot gnu.org @ 2022-04-09 6:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105130 Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org --- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> --- Please send your patch to the gcc-patches mailing list for review. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/105130] gcc does not warn about unused return value of last expression of statement expr 2022-04-01 19:55 [Bug c++/105130] New: gcc does not warn about unused return value of last expression of statement expr dani at danielbertalan dot dev 2022-04-01 20:14 ` [Bug c++/105130] " dani at danielbertalan dot dev 2022-04-09 6:37 ` egallager at gcc dot gnu.org @ 2022-11-28 18:25 ` pinskia at gcc dot gnu.org 2022-11-28 18:30 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-11-28 18:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105130 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I would have thought this was by design. a statement expression last statement is "used" there. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/105130] gcc does not warn about unused return value of last expression of statement expr 2022-04-01 19:55 [Bug c++/105130] New: gcc does not warn about unused return value of last expression of statement expr dani at danielbertalan dot dev ` (2 preceding siblings ...) 2022-11-28 18:25 ` pinskia at gcc dot gnu.org @ 2022-11-28 18:30 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-11-28 18:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105130 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=39808 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- PR 39808 is the C version. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-28 18:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-01 19:55 [Bug c++/105130] New: gcc does not warn about unused return value of last expression of statement expr dani at danielbertalan dot dev 2022-04-01 20:14 ` [Bug c++/105130] " dani at danielbertalan dot dev 2022-04-09 6:37 ` egallager at gcc dot gnu.org 2022-11-28 18:25 ` pinskia at gcc dot gnu.org 2022-11-28 18:30 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).