[cfe-dev] [libc++] (Yet) more places to use std::addressof

Eric Fiselier via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 30 20:29:45 PDT 2015


I think we can be a lot better at testing for this kind of defect by
pre-including the following operator definition
in each test.

    namespace std {
      template <class Tp>
      void operator&(Tp&&) {
static_assert(TypeDependantFalse<Tp>::value, "This operator should
never be instantiated"); }
    }

I suggest putting it in namespace std so that most uses of operator&
in the test suite continue to work.

I'll take a look at doing this and hopefully we won't run into this
kind of bug again.

/Eric

On Wed, Sep 30, 2015 at 1:01 PM, Marshall Clow via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> On Fri, Sep 18, 2015 at 4:38 AM, Sebastian Theophil via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>>
>> Hi,
>>
>> This just bit me. In lines 386 and 387 of the utility header,
>> std::addressof should be used:
>>
>>     void
>>     swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value
>> &&
>>                                __is_nothrow_swappable<second_type>::value)
>>     {
>>         _VSTD::iter_swap(&first, &__p.first);
>>         _VSTD::iter_swap(&second, &__p.second);
>>     }
>>
>>
> Thanks for the bug report; this has been fixed in a better way ;-)
>
> -- Marshall
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list