Commit b5c433ce by Jonathan Wakely Committed by Jonathan Wakely

Improve precondition checks for std::span

	* doc/xml/manual/status_cxx2020.xml: Update status for P0122R7 and
	P1024R3. Remove entry for P0920R2.
	* include/std/span  (__cpp_lib_span): Change value.
	(__extent_storage, __extent_storage<dynamic_extent>): Remove default
	constructor.
	(span): Replace __extent_storage base class with data member.
	(span::_S_subspan_extent): New function.
	(span::empty()): Add nodiscard attribute.
	(span::front, span::back, span::operator[]): Check preconditions.
	(span::first, span::last, span::subspan): Add noexcept. Improve
	precondition checks (LWG 3103).
	(get): Remove redundant condition from static_assert.
	(tuple_element<I, span<T, E>>): Fix static_assert message and simplify.
	(as_writable_bytes): Add inline specifier.
	* include/std/version (__cpp_lib_span): Change value.
	* testsuite/23_containers/span/back_neg.cc: Remove stray semi-colon.
	* testsuite/23_containers/span/front_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_neg.cc: Likewise.
	* testsuite/23_containers/span/last_neg.cc: Improve test.
	* testsuite/23_containers/span/subspan_neg.cc: Likewise.
	* testsuite/23_containers/span/1.cc: New test.
	* testsuite/23_containers/span/2.cc: New test.
	* testsuite/23_containers/span/back_assert_neg.cc: New test.
	* testsuite/23_containers/span/first_2_assert_neg.cc: New test.
	* testsuite/23_containers/span/first_assert_neg.cc: New test.
	* testsuite/23_containers/span/first_neg.cc: New test.
	* testsuite/23_containers/span/front_assert_neg.cc: New test.
	* testsuite/23_containers/span/index_op_assert_neg.cc: New test.
	* testsuite/23_containers/span/last_2_assert_neg.cc: New test.
	* testsuite/23_containers/span/last_assert_neg.cc: New test.
	* testsuite/23_containers/span/subspan_2_assert_neg.cc: New test.
	* testsuite/23_containers/span/subspan_3_assert_neg.cc: New test.
	* testsuite/23_containers/span/subspan_4_assert_neg.cc: New test.
	* testsuite/23_containers/span/subspan_5_assert_neg.cc: New test.
	* testsuite/23_containers/span/subspan_6_assert_neg.cc: New test.
	* testsuite/23_containers/span/subspan_assert_neg.cc: New test.

From-SVN: r275411
parent 55e8f926
2019-09-05 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/status_cxx2020.xml: Update status for P0122R7 and
P1024R3. Remove entry for P0920R2.
* include/std/span (__cpp_lib_span): Change value.
(__extent_storage, __extent_storage<dynamic_extent>): Remove default
constructor.
(span): Replace __extent_storage base class with data member.
(span::_S_subspan_extent): New function.
(span::empty()): Add nodiscard attribute.
(span::front, span::back, span::operator[]): Check preconditions.
(span::first, span::last, span::subspan): Add noexcept. Improve
precondition checks (LWG 3103).
(get): Remove redundant condition from static_assert.
(tuple_element<I, span<T, E>>): Fix static_assert message and simplify.
(as_writable_bytes): Add inline specifier.
* include/std/version (__cpp_lib_span): Change value.
* testsuite/23_containers/span/back_neg.cc: Remove stray semi-colon.
* testsuite/23_containers/span/front_neg.cc: Likewise.
* testsuite/23_containers/span/index_op_neg.cc: Likewise.
* testsuite/23_containers/span/last_neg.cc: Improve test.
* testsuite/23_containers/span/subspan_neg.cc: Likewise.
* testsuite/23_containers/span/1.cc: New test.
* testsuite/23_containers/span/2.cc: New test.
* testsuite/23_containers/span/back_assert_neg.cc: New test.
* testsuite/23_containers/span/first_2_assert_neg.cc: New test.
* testsuite/23_containers/span/first_assert_neg.cc: New test.
* testsuite/23_containers/span/first_neg.cc: New test.
* testsuite/23_containers/span/front_assert_neg.cc: New test.
* testsuite/23_containers/span/index_op_assert_neg.cc: New test.
* testsuite/23_containers/span/last_2_assert_neg.cc: New test.
* testsuite/23_containers/span/last_assert_neg.cc: New test.
* testsuite/23_containers/span/subspan_2_assert_neg.cc: New test.
* testsuite/23_containers/span/subspan_3_assert_neg.cc: New test.
* testsuite/23_containers/span/subspan_4_assert_neg.cc: New test.
* testsuite/23_containers/span/subspan_5_assert_neg.cc: New test.
* testsuite/23_containers/span/subspan_6_assert_neg.cc: New test.
* testsuite/23_containers/span/subspan_assert_neg.cc: New test.
2019-09-05 JeanHeyd Meneide <phdofthehouse@gmail.com>
* include/Makefile.am: Add <span> header.
......
......@@ -1109,11 +1109,11 @@ Feature-testing recommendations for C++</a>.
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0777r1.pdf" target="_top">
P0777R1
</a>
</td><td align="center"> 9.1 </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> <code class="code">&lt;span&gt;</code> </td><td align="left">
</td><td align="center"> 9.1 </td><td align="left"> </td></tr><tr><td align="left"> <code class="code">&lt;span&gt;</code> </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0122r7.pdf" target="_top">
P0122R7
</a>
</td><td align="center"> </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Extending chrono to Calendars and Time Zones </td><td align="left">
</td><td align="center"> 10.1 </td><td align="left"> <code class="code">__cpp_lib_span &gt;= 201803L</code> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Extending chrono to Calendars and Time Zones </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0355r7.html" target="_top">
P0355R7
</a>
......@@ -1430,17 +1430,13 @@ Feature-testing recommendations for C++</a>.
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1252r2.pdf" target="_top">
P1252R2
</a>
</td><td align="center"> </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left">
</td><td align="center"> </td><td align="left"> </td></tr><tr><td align="left">
Usability Enhancements for <code class="classname">std::span</code>
</td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1024r3.pdf" target="_top">
P1024R3
</a>
</td><td align="center"> </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Precalculated hash values in lookup </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0920r2.html" target="_top">
P0920R2
</a>
</td><td align="center"> </td><td align="left"> </td></tr><tr><td align="left"> Traits for [Un]bounded Arrays </td><td align="left">
</td><td align="center"> 10.1 </td><td align="left"> <code class="code">__cpp_lib_span &gt;= 201902L</code> </td></tr><tr><td align="left"> Traits for [Un]bounded Arrays </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1357r1.pdf" target="_top">
P1357R1
</a>
......
......@@ -237,15 +237,14 @@ Feature-testing recommendations for C++</link>.
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry> <code>&lt;span&gt;</code> </entry>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0122r7.pdf">
P0122R7
</link>
</entry>
<entry align="center"> </entry>
<entry />
<entry align="center"> 10.1 </entry>
<entry> <code>__cpp_lib_span &gt;= 201803L</code> </entry>
</row>
<row>
......@@ -1111,7 +1110,6 @@ Feature-testing recommendations for C++</link>.
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>
Usability Enhancements for <classname>std::span</classname>
</entry>
......@@ -1120,20 +1118,8 @@ Feature-testing recommendations for C++</link>.
P1024R3
</link>
</entry>
<entry align="center"> </entry>
<entry />
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry> Precalculated hash values in lookup </entry>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0920r2.html">
P0920R2
</link>
</entry>
<entry align="center"> </entry>
<entry />
<entry align="center"> 10.1 </entry>
<entry> <code>__cpp_lib_span &gt;= 201902L</code> </entry>
</row>
<row>
......
......@@ -166,10 +166,8 @@
#endif
#define __cpp_lib_list_remove_return_type 201806L
#define __cpp_lib_math_constants 201907L
#define __cpp_lib_span 201902L
#define __cpp_lib_to_array 201907L
// FIXME: they forgot this feature test macro
// get on someone's back about it in Belfast!!!
#define __cpp_lib_span 201911
#endif // C++2a
#endif // C++17
#endif // C++14
......
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
#ifndef __cpp_lib_span
# error "Feature-test macro for span missing in <span>"
#elif __cpp_lib_span != 201902L
# error "Feature-test macro for span has wrong value in <span>"
#endif
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <version>
#ifndef __cpp_lib_span
# error "Feature-test macro for span missing in <version>"
#elif __cpp_lib_span != 201902L
# error "Feature-test macro for span has wrong value in <version>"
#endif
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
std::span<int, std::dynamic_extent> s;
s.back();
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
void
test01()
{
std::span<int, 0> s;
s.back(); // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.first(5);
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.first<5>();
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
void
test01()
{
int a[4];
std::span<int, 4> s(a);
s.first<5>(); // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
std::span<int, std::dynamic_extent> s;
s.front();
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
void
test01()
{
std::span<int, 0> s;
s.front(); // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
std::span<int, std::dynamic_extent> s;
s[99];
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
void
test01()
{
std::span<int, 0> s;
s[99]; // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.last(5);
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.last<5>();
}
......@@ -15,15 +15,16 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++2a" }
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
int
main()
void
test01()
{
std::span<int, 2> myspan(nullptr, 2);
myspan.last<3>(); // { dg-error "here" }
int a[2];
std::span<int, 2> s(a);
s.last<3>(); // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.subspan<2, 5>();
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.subspan<2, 3>();
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.subspan(5, 0);
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.subspan(2, 5);
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.subspan(2, 3);
}
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++2a" }
// { dg-do run { xfail c++2a } }
#define _GLIBCXX_ASSERTIONS
#include <span>
int main()
{
int a[4];
std::span<int, std::dynamic_extent> s(a);
s.subspan<5, 0>();
}
......@@ -15,15 +15,33 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=c++2a" }
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
#include <span>
int
main()
void
test01()
{
std::span<int, 2> myspan(nullptr, 2);
myspan.subspan<3, 1>(); // { dg-error "here" }
int a[4];
std::span<int, 4> s(a);
s.subspan<5, 0>(); // { dg-error "here" }
}
void
test02()
{
int a[4];
std::span<int, 4> s(a);
s.subspan<3, 5>(); // { dg-error "here" }
}
void
test03()
{
int a[4];
std::span<int, 4> s(a);
s.subspan<3, 2>(); // { dg-error "here" }
}
// { dg-error "static assertion failed" "" { target *-*-* } 0 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment