CC icon indicating copy to clipboard operation
CC copied to clipboard

Incomplete type analysis?

Open P-p-H-d opened this issue 1 year ago • 2 comments

For the following program which is faulty (it gives an integer instead of a structure as argument of the map for the insert call),

#include <stdio.h>
#include <string.h>
#include "cc.h"

typedef struct { int x, y, z; } mp;
#define CC_CMPR mp, { return memcmp( &val_1, &val_2, sizeof (mp)); }
#define CC_HASH mp, { return val.x ^ val.y ^ val.z; }
#include "cc.h"

int main( void )
{
  map(mp, mp) map;
  init(&map);
  if (!insert(&map, 12, 12)) {
    abort();
  }
  cleanup(&map);
  return 0;
}

the compilation succeeds with some "missing braces around initializer [-Wmissing-braces]" warnings whereas I was expecting a compilation failure or at least a warning about incompatible pointer.

P-p-H-d avatar Mar 30 '23 22:03 P-p-H-d