News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Invalid jump into VLA block

Started by Marco, Today at 04:14:58 PM

Previous topic - Next topic

Marco

Hello,

While maintaining the code for one of my apps, the compiler displayed the following error message:

error #2211: Invalid jump into 'VLA' block.

After running several tests, I managed to identify the cause of the error and reproduce the problem with a simpler project:

#include <excpt.h>
#include <stdio.h>

// function prototype.
void foo(int);

int main(int argc, char *argv[])
{
  return 0;
}
 
void foo(int a)
{
  __try {

      size_t bufSize = 1234;
      char buffer[bufSize];         // <-- (1)
      int b = a ? 1 : 2;            // <-- (2) - Any ternary operator.

  }
  __except (EXCEPTION_EXECUTE_HANDLER) {
      printf("An exception occurred - the code is %x\n", exception_code());
  }
}

The __try-__except statement is based on the example in the help file.
When building, the compiler should give some warnings that can be ignored for the sake of this example.
It seems that the error is caused by the combination of instructions (1) and (2).

Changing instruction (1) to

char buffer[1234];

or instruction (2) to

int b=2;
if (a) b=1;

fixes the issue.

The error occurs whether optimizations are turned on or off, and whether the target processor is 32-bit or 64-bit.
If it's useful, the following options were used with POCC for compilation: -fp:precise -W2 -Gz -Ze -Zx.

Marco