The core of the problem is that numeric constant 0
or 1
are of type int. When we serialise AST, we use something like fprinf (out, "foo (1, %zu)", some_sizet_var)
, which prints to 0
, which is int by default. The function definition of foo is something like:
size_t
foo (size_t count, ...) {
va_start (ap, count);
size_t x = va_arg (ap, size_t);
va_end ();
return x;
}
For more information see #2242 (closed). In this MR at serialisation time we generate not just a numerical value, but also a static assertion that this value is of the right type. The static assertion will terminate compilation of tree files in case the sizes don't match.