[Bug c++/109235] nodiscard attribute on class not copied to the constructors

2023-03-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235

--- Comment #6 from Jonathan Wakely  ---
(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

[Bug c++/109235] nodiscard attribute on class not copied to the constructors

2023-03-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|NEW |RESOLVED

--- Comment #5 from Andrew Pinski  ---
Dup of bug 85973.

*** This bug has been marked as a duplicate of bug 85973 ***

[Bug c++/109235] nodiscard attribute on class not copied to the constructors

2023-03-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235

--- Comment #4 from Andrew Pinski  ---
(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.

[Bug c++/109235] nodiscard attribute on class not copied to the constructors

2023-03-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109235

Andrew Pinski  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  ---
If we move the nodiscard to the constructor, GCC errors out correctly.