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

            Bug ID: 111159
           Summary: [13 Regression] False positive -Wdangling-reference
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel at constexpr dot org
  Target Milestone: ---

GCC 13.2.0 as well as git from today report a false positive
-Wdangling-reference warning for the following C++ code:

struct A {
        int * i;
        int & b() { return *i; }
};

int g = 42;

A a() {
        return A{ &g };
}

int main() {
        const int & i = a().b();
        return i;
}

Reply via email to