View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001729 | OpenFOAM | Bug | public | 2015-06-02 20:21 | 2015-06-02 20:41 |
Reporter | roenby | Assigned To | henry | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | GNU/Linux | OS | Ubuntu | OS Version | 12.04 |
Summary | 0001729: Wrong behaviour when appending vector to vectorField? | ||||
Description | This code: vectorField test; vector t1(1.0,2.0,3.0); test.append(t1); vector& t2 = test[0]; test.append(t2); Info << "test = " << test << endl; results in the following output: test = 2((1 2 3) (0 2 3)) The first component of the appended vector is not appended correctly. | ||||
Steps To Reproduce | See code above. | ||||
Tags | No tags attached. | ||||
|
What happens when you run this in valgrind? Does the behavior change if you use a copy rather than a reference: vector t2 = test[0]; |
|
vector t2 = test[0]; results in the expected behaviour: test = 2{(1 2 3)} Have not tried it with valgrind. |
|
The issue is that you are holding a reference to an element that will be copied when the list is resized, this is likely to corrupt the memory which valgrind will show. To avoid the problem hold a copy of rather than a reference to the data which will move. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-06-02 20:21 | roenby | New Issue | |
2015-06-02 20:26 | henry | Note Added: 0004880 | |
2015-06-02 20:32 | roenby | Note Added: 0004881 | |
2015-06-02 20:41 | henry | Note Added: 0004882 | |
2015-06-02 20:41 | henry | Status | new => resolved |
2015-06-02 20:41 | henry | Resolution | open => fixed |
2015-06-02 20:41 | henry | Assigned To | => henry |