C2 forum
General Category => General Discussion => Topic started by: shiv on March 08, 2017, 04:59:55 AM
-
The following code:
module test;
import stdio;
public func int32 main () {
const uint64[2] Dims = {2, 3}
float32[Dims[0]][Dims[1]] p;
p[0][0] = 1;
p[0][1] = 2;
stdio.printf ("%g %g", p[0][0], p[0][1]);
return 0;
}
causes the following error:
c2c: /home/shiv/c2compiler/c2c/CGenerator/CCodeGenerator.cpp:485: void C2::CCodeGenerator::EmitDecl(const C2::Decl *, C2::StringBuilder &): Assertion `D' failed.
Aborted (core dumped)
Not sure what Assert 'D' is?
Thanks.
--shiv--
-
Good one!
I'll turn it into a unit test and fix it this evening..
-
The issue reproduces nicely indeed. There seem to be several issues here. The first one
is that array subscript expressions were not marked at compile-time-constant (if they were).
That is fixed on a branch now. Since C2 allows more then C sometimes, I'll look carefully
at the order of evaluation, since it's otherwise easy to get loops in constant declarations
that we have to detect/avoid..
-
I just installed C2 again and this issue does not appear to be fixed at least if I install c2 according to the installation instructions on the github home page. I know you said that you would fix this in another branch. If so, please let me know how to proceed and I will be happy to try it out. Thanks.
--shiv--
-
Actually please ignore that request. I realized that C support for multidimensional arrays is broken anyway so I will just use the vanilla 1D arrays instead.
Thanks.
--shiv--