On 15/12/20 15:20 +0000, Jonathan Wakely wrote:
On 14/12/20 22:36 +0100, François Dumont wrote:
On 14/12/20 11:08 am, Jonathan Wakely wrote:
On Mon, 14 Dec 2020, 06:51 François Dumont via Libstdc++,
<libstd...@gcc.gnu.org <mailto:libstdc%2b...@gcc.gnu.org>> wrote:
On 13/12/20 11:17 pm, Jonathan Wakely wrote:
> On 13/12/20 15:52 +0100, François Dumont via Libstdc++ wrote:
>> Some tests are XPASS because array assertions have been
disabled for
>> a good reason in C++11.
>>
>> I wonder if the respective non-constexpr _GLIBCXX_ASSERTION checks
>> shouldn't target C++14 too. At the moment they are failing as
>> expected but because of an Undefined Behavior no ?
>
> Hmm, maybe my "fix" for the bug was too hasty, and I should have
done
> this instead:
>
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -684,7 +684,7 @@ namespace std
>
> Â #undef _GLIBCXX_HAS_BUILTIN
>
> -#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
> +#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED && __cplusplus >=
> 201402L
> Â # define __glibcxx_assert_1(_Condition)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â \
> Â Â Â Â if (__builtin_is_constant_evaluated())Â Â Â Â \
> Â Â Â Â Â {Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
        \
>
> That would allow us to keep the std::array runtime assertions for
> C++11, and only disable them in constexpr contexts.
I already tried to restore this check in C++11 runtime without
success
but I didn't try this approach.
I'll have a try but C++11 forces constexpr to be just a return
statement
so I fear that it won't appreciate the additional assertion.
Ah yes, we'd need something like Daniel suggested, and it's not
worth it just for C++11.
Just limiting the tests to c++14 is fine.
Attached patch committed then.
Thanks.
I'm committing this anyway, because although it won't fix those tests,
it is useless to check __builtin_is_constant_evaluated() in C++11
mode.
Tested powerpc64le-linux, normal mode and debug mode. Pushed to trunk.
commit f072d1021e3e80539afe58ba0019fafa9a0bb7a6
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Tue Dec 15 15:39:58 2020
libstdc++: Do not define constexpr assertions for C++11
There's no point even checking is_constant_evaluated() in C++11 mode,
because the 'if' statement used for the assertion wouldn't be valid in a
C++11 constexpr function anyway.
libstdc++-v3/ChangeLog:
* include/bits/c++config (__glibcxx_assert_1): Define as empty
for C++11.
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 27302ed392e..155d0f46b16 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -684,7 +684,7 @@ namespace std
#undef _GLIBCXX_HAS_BUILTIN
-#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED && __cplusplus >= 201402L
# define __glibcxx_assert_1(_Condition) \
if (__builtin_is_constant_evaluated()) \
{ \