New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated use of subexpressions can lead to attempted redefinition of constant in C code #880

mstimberg opened this Issue Sep 14, 2017 · 0 comments


None yet
1 participant

mstimberg commented Sep 14, 2017

In generated code (already on the level of "statements", i.e. before we create C++/Cython/... code), repeatedly used subexpressions are not handled correctly.
If a = z is a subexpression, then writing abstract code like this:

x = a
x = a

will lead to a compilation error in weave, because we (correctly) derive that a is constant because z does not change, but we still re-define it later:

z = array_...;
const double a = z;
double x = a;
a = z;  // <-- not allowed
x = a;

I guess this was somewhat of a corner case before (obviously we did not have a test covering this situation), but it gets triggered fairly easy now with the changes I made to synapse generation in #854. In fact, it gets triggered by one of our tutorial examples...

I'll open a PR with the fix in a minute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment