2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / cast.C
blob75ab0e8cef6ba38794d8469cada1c47b164e544d
1 // I, Howard Hinnant, hereby place this code in the public domain.
3 // Test cast from lvalue to rvalue
5 // { dg-do compile { target c++11 } }
6 // { dg-skip-if "packed attribute missing for struct one" { "epiphany-*-*" } }
8 template <bool> struct sa;
9 template <> struct sa<true> {};
11 struct one   {long x[1];};
12 struct two   {long x[2];};
14 struct A {};
16 one foo(const A&) {return one();}
17 two foo(A&&)      {return two();}
19 int test1()
21     A a;
22     sa<sizeof(foo(a)) == 1 * sizeof(long)> t1;
23     sa<sizeof(foo(static_cast<A&&>(a))) == 2 * sizeof(long)> t2;
24     return 0;
27 int main()
29     return test1();