PR c++/23357
[official-gcc.git] / gcc / testsuite / g++.dg / expr / lval2.C
blob5d062f1c62889494963c7e3d23db476574eaa9ae
1 // PR c++/19199
3 // { dg-do run }
5 // We used to turn the COND_EXPR lvalue into a MIN_EXPR rvalue, and
6 // then return a reference to a temporary in qMin.
8 #include <assert.h>
10 enum Foo { A, B };
12 template<typename T> T &qMin(T &a, T &b) 
14   return a < b ? a : b;
17 int main (int,  char **)
19   Foo f = A;
20   Foo g = B;
21   Foo &h = qMin(f, g);
22   assert (&h == &f || &h == &g);
23   const Foo &i = qMin((const Foo&)f, (const Foo&)g);
24   assert (&i == &f || &i == &g);
25   return 0;