mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libstdc++: bitset _GLIBCXX_ASSERTIONS op[] fixes
C++11 forbids a compound statement, as seen in the definition
of __glibcxx_assert(), in a constexpr function. This patch
open-codes the assertion in `bitset<>::operator[] const` for
C++11 to fix a failure in `g++.old-deja/g++.martin/bitset1.C`.
Also, it adds `{ dg-do compile }` in another test to suppress
a spurious UNRESOLVED complaint.
libstdc++-v3/ChangeLog:
* include/std/bitset (operator[]() const): Customize bounds
check for C++11 case.
* testsuite/20_util/bitset/access/subscript_const_neg.cc:
Suppress UNRESOLVED complaint.
This commit is contained in:
@@ -1298,8 +1298,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||
_GLIBCXX_CONSTEXPR bool
|
||||
operator[](size_t __position) const
|
||||
{
|
||||
#if __cplusplus != 201103L
|
||||
__glibcxx_assert(__position < _Nb);
|
||||
return _Unchecked_test(__position);
|
||||
#elif defined(_GLIBCXX_ASSERTIONS)
|
||||
// C++11 forbids a compound stmt in a constexpr function.
|
||||
return __position < _Nb ? _Unchecked_test(__position)
|
||||
: (__builtin_trap(), false);
|
||||
#else
|
||||
return _Unchecked_test(__position);
|
||||
#endif
|
||||
}
|
||||
///@}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// { dg-do compile }
|
||||
#include <bitset>
|
||||
|
||||
void test_const_subscript_assignment()
|
||||
|
||||
Reference in New Issue
Block a user