Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Variable lenght array

$
0
0

Hi all!

Although this code has many features that are strictly forbidden by the C standard I think most of them are supported as Intel extensions.

#include <stdlib.h>
#include <stdio.h>

#if defined(RANK)
#define IRANK RANK
#else
#define IRANK 0
#endif

#define MSTRUCT(r) struct{int dim[r];}

int main(int argc, char **argv){
  int        n = IRANK;
  MSTRUCT(n) s;
 
  printf("%zu, %zu\n", sizeof(s), sizeof(MSTRUCT(n)));
  return EXIT_SUCCESS;
}

I would expect the code to print two identical numbers.

Using -ftrapuv changes the value printed, -O0 had the same effect on a more complicated variation.

Thank you very much.

Best regards,

José Rui

 


Viewing all articles
Browse latest Browse all 1175

Trending Articles