[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
valarray help
From: |
Mephistopheles Jones |
Subject: |
valarray help |
Date: |
Thu, 07 Apr 2005 18:48:13 -0700 |
User-agent: |
Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
I'm having trouble when using a valarray as a class member. I compile
with g++, and my gcc is version 3.3.5. Here's a highly simplified example:
struct ValWrapper {
valarray<int> item;
};
int main() {
ValWrapper v;
v.item=valarray<int>(-1,10);
v.item[1]=23; // <--- segfault here
return 0;
}
The assignment in the penultimate line of main gives a segfault. However,
when I do this
int main() {
valarray<int> v(-1,10);
v[1]=23;
return 0;
}
all works fine. Replacing all instances of "valarray" with "vector" above
gives an error as well, but curiously the errors are different. I get
"Segmentation fault (core dumped)" for valarrays and "Aborted (core
dumped)" for vectors. I believe my assignments are syntactically correct.
Any pointers? Thanks in advance.
Meph
- valarray help,
Mephistopheles Jones <=