[libcxx] r187552 - Constrain fill_n -> memset operations to include implicit convertibility to unsigned char. This fixes http://llvm.org/bugs/show_bug.cgi?id=16764. Also a drive-by fix on a chrono test suite bug.

Eli Friedman eli.friedman at gmail.com
Wed Jul 31 22:34:06 PDT 2013


On Wed, Jul 31, 2013 at 5:41 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> Author: hhinnant
> Date: Wed Jul 31 19:41:55 2013
> New Revision: 187552
>
> URL: http://llvm.org/viewvc/llvm-project?rev=187552&view=rev
> Log:
> Constrain fill_n -> memset operations to include implicit convertibility to unsigned char.  This fixes http://llvm.org/bugs/show_bug.cgi?id=16764.  Also a drive-by fix on a chrono test suite bug.
>
> Modified:
>     libcxx/trunk/include/algorithm
>     libcxx/trunk/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
>
> Modified: libcxx/trunk/include/algorithm
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=187552&r1=187551&r2=187552&view=diff
> ==============================================================================
> --- libcxx/trunk/include/algorithm (original)
> +++ libcxx/trunk/include/algorithm Wed Jul 31 19:41:55 2013
> @@ -2012,6 +2012,7 @@ fill_n(_OutputIterator __first, _Size __
>     return _VSTD::__fill_n(__first, __n, __value_, integral_constant<bool,
>                                                is_pointer<_OutputIterator>::value &&
>                                                is_trivially_assignable<typename remove_pointer<_OutputIterator>::type, _Tp>::value &&
> +                                              is_convertible<_Tp, unsigned char>::value &&
>                                                sizeof(typename remove_pointer<_OutputIterator>::type) == 1>());
>  }

Is is_convertible really the right constraint here?  Suppose, for
example, a class of size one with an conversion operator which returns
some other value.

-Eli



More information about the cfe-commits mailing list