blob: 775507f8de86474aee02b7766ea01741f2775fce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Test for range-based for loop
// Test the loop with an initializer_list
// { dg-do run }
// { dg-options "-std=c++0x" }
#include <initializer_list>
extern "C" void abort();
template<typename T> T foo()
{
T sum = 0;
for (T x : {T(1),T(2),T(3),T(4)})
sum += x;
if (sum != T(10))
abort();
}
int main()
{
int sum = 0;
for (int x : {1,2,3,4})
sum += x;
if (sum != 10)
abort();
foo<int>();
}
|