lmi
[Top][All Lists]
Advanced

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

Re: [lmi] g++-12 valarray defect


From: Vadim Zeitlin
Subject: Re: [lmi] g++-12 valarray defect
Date: Wed, 17 Aug 2022 02:40:24 +0200

On Wed, 17 Aug 2022 00:09:06 +0000 Greg Chicares <gchicares@sbcglobal.net> 
wrote:

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

 I can confirm that I can reproduce the problem here too, just by adding
-Walloc-zero and -O1 (or greater) flags to the compiler command line.

 Have you considered reporting this to gcc? I can't find any existing bug
reports about this in their bug tracker.

 FWIW fixing it seems to be trivial, as it would be enough to check that
the size is not 0 and not call __valarray_get_storage in this case, but
this needs to be in libstdc++ itself, of course.

 Another note is that the only meaningful change between gcc 11 and 12
versions of this header that I see are the additions of _GLIBCXX_NOTHROW
here and there, so apparently their absence in gcc 11 version prevented the
compiler from producing the warning, which should have been given even
there (as copying an empty valarray still resulted in allocating a buffer
of size 0).

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

 Yes, I guess this is the explanation. But it doesn't really help dealing
with this warning, unfortunately.

 Regards,
VZ

Attachment: pgpqgp1eO02rg.pgp
Description: PGP signature


reply via email to

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