https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108238

            Bug ID: 108238
           Summary: returns_nonnull attribute with auto return type fails
                    to compile
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pobrn at protonmail dot com
  Target Milestone: ---

See the following example code (https://gcc.godbolt.org/z/76vPhPe6z):

    [[gnu::returns_nonnull]]
    auto f() {
        return new int(42);
    }

It produces the following error:

    <source>:2:8: error: 'returns_nonnull' attribute on a function not
returning a pointer
    2 | auto f() {
      |        ^

I think this should compile.

Reply via email to