https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61528
Bug ID: 61528 Summary: std::min std::max and RValue Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lisp2d at lisp2d dot net Declaring reference of result of functions MIN or MAX we get a DEAD memory when one of arguments is an RValue. // gcc -std=c++11 -Os bug.cpp // gcc -std=c++11 -O2 bug.cpp #include<iostream> void f(size_t const & x){ std::cout << "f:x=" << x << std::endl;} int main(void){ size_t x{1}; size_t y{2}; size_t z{4}; size_t const & i=std::min(z,x + y); f(i); size_t const & a=std::max(x,y + z); f(a);}