Open
Description
When building hostboot with a newer GCC (see open-power/op-build#4595):
../../../../src/include/util/impl/unique_ptr.H:408:30: error: cannot
bind rvalue reference of type ‘std::enable_if<true, STDUniquePtrTest::practice_struct&&>::type’
{aka ‘STDUniquePtrTest::practice_struct&&’} to lvalue of type ‘STDUniquePtrTest::practice_struct’
408 | return iv_ptr[i];
The failure is in the test case (no in hostboot seems to trigger it) here https://github.com/open-power/hostboot/blob/master-p10/src/usr/testcore/lib/unique_ptr.H#L116
i[4].x = 99;
if (i[4].x != 99)
{
TS_FAIL("Array access through unique_ptr returned incorrect value (expected 99)");
}
if (i[3].x != 4)
{
TS_FAIL("Array access through unique_ptr returned incorrect value (expected 4)");
}
Removing this code allows the build to complete. However, this code seems to be valid. If we build it using GCC's unique_ptr.h, it compiles and the test case runs.
I don't understand what the templates are doing here, but it seems they are the cause of the problem:
/* @brief Index operator for unique_ptr<T[]>.
*
* operator[] is not callable on a unique_ptr to non-array types.
*
* @param[in] i Index into the array
* @return Value of T::operator[](i)
*/
template<typename Index, typename X = T>
typename enable_if<is_array<X>::value, decltype(declval<X>()[declval<Index>()])>::type
operator[](const Index i)
{
return iv_ptr[i];
}
Metadata
Metadata
Assignees
Labels
No labels