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: [[patch] valarray (was Re: valarray_copy implementation question)


I think I understand your point. dest[b] has 0 size because there were 0 matching elements, correct ? your definition of size of dest[b] is the number of true elements.

What I found really strange with this interpretation is that the legality of the program depends on a runtime behavior

for instance if the boolean's value is not known at compile time, like with

...
b[0] = foo(); // with extern bool foo (void);
dest[b] = src;
...

Is this legal or not ? that's quite disturbing :-( I know a couple of proprietary and commercial testsuite that fail on this kind of test. (having n true elements < at the size of src).

Thanks so much and sorry for the noise.

Christian


Gabriel Dos Reis wrote:
On Thu, Nov 26, 2009 at 5:58 AM, Christian BRUEL <christian.bruel@st.com> wrote:
what about

#include <valarray>
using namespace std;

int main(void)
{
 int n = 1;

 valarray<int>  dest(n);
 valarray<bool> b(false, n);
 valarray<int>  src(1, n);

dest[b] = src;

Christian,


  the array expression `dest[b]' has length 0; the array expression `src'
has length 1.  That violates the equal length precondition.

 return 0;
}

is it a user error also ?

yes; it is user confusion; the same as we discussed before.


-- Gaby



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