[Bug c++/64372] New: Spurious warning with throw in ternary operator returning const reference
tavianator at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Dec 21 18:43:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372
Bug ID: 64372
Summary: Spurious warning with throw in ternary operator
returning const reference
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tavianator at gmail dot com
The following program produces a spurious warning:
$ cat ternary-warning.cpp
const char&
foo(const char* ptr)
{
return ptr ? *ptr : throw ptr;
}
$ g++ -Wall -c ternary-warning.cpp
ternary-warning.cpp: In function ‘const char& foo(const char*)’:
ternary-warning.cpp:4:29: warning: returning reference to temporary
[-Wreturn-local-addr]
return ptr ? *ptr : throw ptr;
^
More information about the Gcc-bugs
mailing list