This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add __gnu_test::NullablePointer utility to testsuite


On 14/05/19 19:09 +0200, Daniel Krügler wrote:
Am Di., 14. Mai 2019 um 13:20 Uhr schrieb Jonathan Wakely <jwakely@redhat.com>:

        * testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc:
        Use operator-> to access raw pointer member.
        * testsuite/23_containers/vector/59829.cc: Likewise.
        * testsuite/23_containers/vector/bool/80893.cc: Likewise.
        * testsuite/libstdc++-prettyprinters/cxx11.cc: Use NullablePointer.
        * testsuite/util/testsuite_allocator.h (NullablePointer): New utility
        for tests.
        (PointerBase, PointerBase_void): Derive from NullablePointer and use
        its constructors and equality operators. Change converting
        constructors to use operator-> to access private member of the other
        pointer type.
        (PointerBase_void::operator->()): Add, for access to private member.
        (operator-(PointerBase, PointerBase)): Change to hidden friend.
        (operator==(PointerBase, PointerBase)): Remove.
        (operator!=(PointerBase, PointerBase)): Remove.

There are probably more places in the testsuite that could use
NullablePointer as a minimally-conforming type that meets the
Cpp17NullablePointer requirements, instead of defining a new type each
time one is needed.

Tested powerpc64le-linux, committed to trunk.


In the primary template of NullablePointer we have:

explicit operator bool() const noexcept { return value == nullptr; }

This is incorrect according to the NullablePointer requirements, it needs to be:

explicit operator bool() const noexcept { return value != nullptr; }

Argh! I changed that to test something and then didn't change it back
before committing.

It looks like we need a testsuite for our testsuite utilities.

Fixed with this patch, tested ppc64le-linux and committed to trunk.

Thanks for the diligent checks!


commit 5c5b3801911e4b47dd496ce024840d390b72023b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue May 14 20:45:53 2019 +0100

    Fix NullablePointer test utility
    
            * testsuite/util/testsuite_allocator.h (NullablePointer::operator bool):
            Fix return value.

diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index ac7dc8ee2c4..d817ac4e838 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -600,7 +600,7 @@ namespace __gnu_test
       NullablePointer() = default;
       NullablePointer(std::nullptr_t) noexcept : value() { }
 
-      explicit operator bool() const noexcept { return value == nullptr; }
+      explicit operator bool() const noexcept { return value != nullptr; }
 
       friend inline bool
       operator==(NullablePointer lhs, NullablePointer rhs) noexcept

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]