Hacker News new | ask | show | jobs
by kazinator 2944 days ago
There is a concern for performance. But that's no reason. Zero initing could be default behavior that can be declared away. E.g.

As a type qualifier keyword:

  { int x, y; /* x and y are zero */ }

  { int noinit x, y; /* x is indeterminate, y is zero */ }
Or as a declaration specifier:

  { noinit x, y; /* both x, y indeterminately-valued */ }
Or a special constant for suppressing zero initialization:

  { int x, y = noinit; /* x zero, y indeterminate */ }
Similarly, unspecified order of evaluation could be supported by explicit request:

  decl (unspec_order) { /* comma-separated list of decl items */
     a[i] = i++; /* UB */
  }

  a[i] = i++; /* well-defined */
2 comments

zero initing is default behavior for static values or structs.

    static int x, y; /* x and y are zero */
Good idea!