public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/109235] New: nodiscard attribute ignored with deduction guide @ 2023-03-21 15:23 tejo@bang-olufsen.dk 2023-03-21 15:25 ` [Bug c++/109235] " pinskia at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: tejo@bang-olufsen.dk @ 2023-03-21 15:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 Bug ID: 109235 Summary: nodiscard attribute ignored with deduction guide Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tejo@bang-olufsen.dk Target Milestone: --- I have tried implementing std::experimental::scope_exit and since this is a RAII object, I marked it with [[nodiscard]] to ensure all instances are assigned to a variable. It appears, however, that GCC ignores the nodiscard attribute when a deduction guide is present. See this Godbolt link for an example: https://godbolt.org/z/v9e8dqW1o Notice how Clang correctly flags the problem. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/109235] nodiscard attribute ignored with deduction guide 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk @ 2023-03-21 15:25 ` pinskia at gcc dot gnu.org 2023-03-21 15:29 ` [Bug c++/109235] nodiscard attribute ignored on temporary created pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-21 15:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 54721 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54721&action=edit Full testcase with -std=c++20 Please attach the testcase next time or put it inline and not just a link to godbolt . ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/109235] nodiscard attribute ignored on temporary created 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk 2023-03-21 15:25 ` [Bug c++/109235] " pinskia at gcc dot gnu.org @ 2023-03-21 15:29 ` pinskia at gcc dot gnu.org 2023-03-21 15:30 ` [Bug c++/109235] nodiscard attribute on class not copied to the constructors pinskia at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-21 15:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2023-03-21 Summary|nodiscard attribute ignored |nodiscard attribute ignored |with deduction guide |on temporary created --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This has nothing to do with deduction guides either. Reduced testcase: ``` struct [[nodiscard]] scope_exit { scope_exit(int); }; int main() { scope_exit{0}; } ``` ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/109235] nodiscard attribute on class not copied to the constructors 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk 2023-03-21 15:25 ` [Bug c++/109235] " pinskia at gcc dot gnu.org 2023-03-21 15:29 ` [Bug c++/109235] nodiscard attribute ignored on temporary created pinskia at gcc dot gnu.org @ 2023-03-21 15:30 ` pinskia at gcc dot gnu.org 2023-03-21 15:31 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-21 15:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|nodiscard attribute ignored |nodiscard attribute on |on temporary created |class not copied to the | |constructors --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- If we move the nodiscard to the constructor, GCC errors out correctly. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/109235] nodiscard attribute on class not copied to the constructors 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk ` (2 preceding siblings ...) 2023-03-21 15:30 ` [Bug c++/109235] nodiscard attribute on class not copied to the constructors pinskia at gcc dot gnu.org @ 2023-03-21 15:31 ` pinskia at gcc dot gnu.org 2023-03-21 15:32 ` pinskia at gcc dot gnu.org 2023-03-22 13:30 ` redi at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-21 15:31 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > If we move the nodiscard to the constructor, GCC errors out correctly. That is true even on the original testcase. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/109235] nodiscard attribute on class not copied to the constructors 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk ` (3 preceding siblings ...) 2023-03-21 15:31 ` pinskia at gcc dot gnu.org @ 2023-03-21 15:32 ` pinskia at gcc dot gnu.org 2023-03-22 13:30 ` redi at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-03-21 15:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|NEW |RESOLVED --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Dup of bug 85973. *** This bug has been marked as a duplicate of bug 85973 *** ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/109235] nodiscard attribute on class not copied to the constructors 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk ` (4 preceding siblings ...) 2023-03-21 15:32 ` pinskia at gcc dot gnu.org @ 2023-03-22 13:30 ` redi at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: redi at gcc dot gnu.org @ 2023-03-22 13:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235 --- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Teis Johansen from comment #0) > I have tried implementing std::experimental::scope_exit N.B. this is already present in the upcoming GCC 13: https://gcc.gnu.org/gcc-13/changes.html#libstdcxx ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-22 13:30 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-21 15:23 [Bug c++/109235] New: nodiscard attribute ignored with deduction guide tejo@bang-olufsen.dk 2023-03-21 15:25 ` [Bug c++/109235] " pinskia at gcc dot gnu.org 2023-03-21 15:29 ` [Bug c++/109235] nodiscard attribute ignored on temporary created pinskia at gcc dot gnu.org 2023-03-21 15:30 ` [Bug c++/109235] nodiscard attribute on class not copied to the constructors pinskia at gcc dot gnu.org 2023-03-21 15:31 ` pinskia at gcc dot gnu.org 2023-03-21 15:32 ` pinskia at gcc dot gnu.org 2023-03-22 13:30 ` redi 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).