https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91871
Bug ID: 91871
Summary: iterator_to_const_iterator() in testsuite_hooks.h
causes valid -Wreturn-stack-address warnings with LLVM
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: brooks at gcc dot gnu.org
Target Milestone: ---
I have been running the libstdc++ testsuite with LLVM, and a recent change in
LLVM's warnings is now causing the iterator_to_const_iterator() function in
testsuite/util/testsuite_hooks.h to produce a "return stack address" warning.
The warning is obviously correct; the relevant code (around line 320) is:
static const_iterator
iterator_to_const_iterator()
{
_Container v;
const_iterator it = v.begin();
const_iterator end = v.end();
return it == end ? v.end() : it;
}
This only "works" because the code is never run; it's only used in compile-time
tests. Nonetheless, it would still be good to use valid code here.