This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: valarray_copy implementation question


OK, as expected the attached reduced case reports a read error with valgrind :

==10504== Invalid read of size 1
==10504== at 0x400D3E: void std::__valarray_copy<int>(std::_Array<int>, unsigned long, std::_Array<int>, std::_Array<bool>) (in /home/bruel/tmp/a.out)
==10504== by 0x400ADB: std::mask_array<int>::operator=(std::valarray<int> const&) const (in /home/bruel/tmp/a.out)
==10504== by 0x4007E0: main (in /home/bruel/tmp/a.out)
==10504== Address 0x4e2a091 is 0 bytes after a block of size 1 alloc'd


compiled with g++ -O2 x86_64-unknown-linux-gnu 3.3.3

and goes into an infinite loop on SH4 with a gcc 4.4

Cheers

Christian

Paolo Carlini wrote:
Gabriel Dos Reis wrote:
I did not consider the interpretation put forward by Christian, although I can
see his point. I suspect I have to double-check what Fortran
does in this case and consider whether it actually is a LWG issue.
Thanks Gaby for your help.
Do you know what other implementations do?
I can check another one. If you can pass me a precise testcase, then I
can give you the data point.

Paolo.

// Test __valarray_copy.  ISO/IEC 14882:1998, 26.3.8.2 mask_array assignment.

// { dg-do run }

#include <valarray>

int main(void)
{
  int n = 1;

  std::valarray<int>  dest (n);   // 0
  std::valarray<bool> b (n);      // false
  std::valarray<int>  src (1, n); // 1

  dest[b] = src; // 0

  if (dest.size () != n)
    return 1;

  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]