Skip to content

Commit 3b7de7f

Browse files
committed
...
1 parent c18be48 commit 3b7de7f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

include/xtl/xsequence.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ namespace xtl
121121
static inline R forward(const T& r)
122122
{
123123
R ret;
124-
std::copy_n(std::begin(r), std::size(r), std::begin(ret));
125-
// std::copy(std::begin(r), std::end(r), std::begin(ret));
124+
// We can not use std::copy here because it gives an array-bounds warning with GCC
125+
std::copy_n(std::begin(r), std::size(ret), std::begin(ret));
126126
return ret;
127127
}
128128
};

test/test_xsequence.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,24 @@ namespace xtl
3939
return result(xtl::forward_sequence<shape_type, T>(arg));
4040
}
4141

42+
template <class T>
43+
auto test_data(T&& arg)
44+
{
45+
using shape_type = std::array<int, 1>;
46+
shape_type a = xtl::forward_sequence<shape_type, T>(arg);
47+
return a;
48+
}
49+
4250
TEST(xsequence, forward_type)
4351
{
4452
std::array<int, 2> a;
45-
std::vector<int> c;
53+
std::vector<int> c(2);
54+
4655
EXPECT_TRUE(test(std::move(a)));
4756
EXPECT_FALSE(test(a));
4857
EXPECT_TRUE(test(c));
4958
EXPECT_TRUE(test(std::move(c)));
59+
EXPECT_EQ(test_data(c)[0], 0);
5060
}
5161

5262
template <class R, class T>

0 commit comments

Comments
 (0)