[all-commits] [llvm/llvm-project] 9dab2e: [clang][Sema] Warn on return of pointer/reference ...

Youngsuk Kim via All-commits all-commits at lists.llvm.org
Mon Mar 4 19:10:32 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9dab2e3064a2ad4d5ce65832d605787dc394cb72
      https://github.com/llvm/llvm-project/commit/9dab2e3064a2ad4d5ce65832d605787dc394cb72
  Author: Youngsuk Kim <joseph942010 at gmail.com>
  Date:   2024-03-04 (Mon, 04 Mar 2024)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaInit.cpp
    M clang/test/Analysis/stack-addr-ps.c

  Log Message:
  -----------
  [clang][Sema] Warn on return of pointer/reference to compound literal (#83741)

Emit a warning if pointer/reference to compound literal is returned from
a function.

In C, compound literals in block scope are lvalues that have automatic
storage duration. In C++, compound literals in block scope are
temporaries.

In either case, returning a pointer/reference to a compound literal can
cause a use-after-free bug.

Fixes #8678



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list