Author Topic: VLA crash  (Read 6995 times)

shiv

  • Newbie
  • *
  • Posts: 12
    • View Profile
VLA crash
« 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--

admin

  • Administrator
  • Newbie
  • *****
  • Posts: 11
    • View Profile
Re: VLA crash
« Reply #1 on: March 13, 2017, 08:04:29 AM »
Good one!
I'll turn it into a unit test and fix it this evening..

bas

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: VLA crash
« Reply #2 on: March 15, 2017, 08:37:44 AM »
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..

shiv

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: VLA crash
« Reply #3 on: May 23, 2018, 07:04:26 PM »
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--

shiv

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: VLA crash
« Reply #4 on: June 04, 2018, 11:49:02 PM »
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--