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; ^