Fixes #1141. The issue is that in c++ std::vector<var> and std::vector<double> are not assignable to one another, so we need to call the assignment that loops over each element of the assigned from vector and does assignment directly to the sub element. If unenforce-initialize is turned on then that vector will not have been filled yet and so we'll be accessing bad memory and getting a seg. This fixes that by checking in find_assignment_idx whether the rhs is array of data types and if so then failing the optimization since the decleration does need to be initialized with NA.
The mre from #1141 was added in the optimization test suite (Much appreciated @joewing!!)
Submission Checklist
[x] Run unit tests
Documentation
[ ] If a user-facing facing change was made, the documentation PR is here:
[x] OR, no user-facing changes were made
Release notes
Bug fix for --O1 when arrays declared in transformed parameters or model were assigned data
Ty! How long until our next release? If it's more than two months than a .2 might be good but otherwise I think it's fine to just put this in the next release.
Summary
Fixes #1141. The issue is that in c++
std::vector<var>
andstd::vector<double>
are not assignable to one another, so we need to call the assignment that loops over each element of the assigned from vector and does assignment directly to the sub element. Ifunenforce-initialize
is turned on then that vector will not have been filled yet and so we'll be accessing bad memory and getting a seg. This fixes that by checking infind_assignment_idx
whether the rhs is array of data types and if so then failing the optimization since the decleration does need to be initialized with NA.The mre from #1141 was added in the optimization test suite (Much appreciated @joewing!!)
Submission Checklist
Release notes
Bug fix for
--O1
when arrays declared intransformed parameters
ormodel
were assigned dataCopyright and Licensing
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)