lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] g++-12 valarray defect


From: Greg Chicares
Subject: [lmi] g++-12 valarray defect
Date: Wed, 17 Aug 2022 00:09:06 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

Minimal reproducible test case:

#include <valarray>
int main(int, char*[])
{
    std::valarray<double> va0;
    std::valarray<double> va1 = va0;
    return 0;
}

Original test case is building 'expression_template_0_test' with g++-12:

In function ‘_Tp* std::__valarray_get_storage(size_t) [with _Tp = double]’,
    inlined from ‘std::valarray<_Tp>& std::valarray<_Tp>::operator=(const 
std::_Expr<_Dom, _Tp>&) [with _Dom = std::__detail::_BinClos<std::__multiplies, 
std::_Expr, std::_ValArray, std::__detail::_BinClos<std::__minus, 
std::_Constant, std::_ValArray, double, double>, double>; _Tp = double]’ at 
/usr/include/c++/12/valarray:850:41,
    inlined from ‘void mete_valarray_typical()’ at 
/opt/lmi/src/lmi/expression_template_0_test.cpp:305:29:
/usr/include/c++/12/bits/valarray_array.h:58:44: error: argument 1 value is 
zero [-Werror=alloc-zero]
   58 |     { return static_cast<_Tp*>(operator new(__n * sizeof(_Tp))); }
      |                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

The relevant part of operator=() is this:

 849 ☞☞☞☞☞☞☞☞  _M_size = __e.size();
 850 ☞☞☞☞☞☞☞☞  _M_data = __valarray_get_storage<_Tp>(_M_size);
 851 ☞☞☞☞☞☞☞☞  std::__valarray_copy_construct(__e, _M_size, 
_Array<_Tp>(_M_data));

so it seems that __e.size() must be zero.

It seems weird that this is a compile-time error, since the
size of the valarray is set dynamically to various values in
the unit test. All I can guess is that evaluating "__e.size()"
doesn't give the actual size of the evaluated expression.

It also seems weird that the warning is given on a system header,
where I thought it would be disregarded. Maybe that's because
it's inlined.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]