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

--- Comment #30 from maic <gnu.ojxq8 at dralias dot com> ---
This bug still exists for our project. To reproduce:


# g++ --version 
g++ (GCC) 13.0.1 20230404 (Red Hat 13.0.1-0)


# cat /tmp/2.cpp 
const int &Select(const int &i, const bool &b) { return i; }
int main() {
  int a;
  const auto &b{Select(a, true)};
}


# g++ -Wdangling-reference /tmp/2.cpp 
/tmp/2.cpp: In function ‘int main()’:
/tmp/2.cpp:4:15: warning: possibly dangling reference to a temporary
[-Wdangling-reference]
    4 |   const auto &b{Select(a, true)};
      |               ^
/tmp/2.cpp:4:23: note: the temporary was destroyed at the end of the full
expression ‘Select(a, true)’
    4 |   const auto &b{Select(a, true)};
      |                 ~~~~~~^~~~~~~~~

Reply via email to