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: t...@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.

Reply via email to