maxmanolov wrote:
Thanks guys, this is really helpful. On why this is scoped to designated
initializers: per @efriedma-quic's breakdown, `int a[N];` and `int b[N] = {0};`
cost Clang nothing because they're bss or trailing zeros, but `int c[] = {[N-1]
= 0};` costs 8 bytes per skipped element in `InitListExpr` before codegen runs.
And that's the OOM from #205472 so the three cases don't behave the same right
now, and a general array-size flag wouldn't fix this without a separate check
at the same spot. The current check only fires in `CheckDesignatedInitializer`
when an array designator's end index reaches the limit, so dense brace lists
and `#embed` aren't affected. Of course, I'm happy to rename if a name like
`-fmax-implicit-init-list-elements` makes that clearer. And the default could
be much higher than 1M since the cost is only a pointer per element. I see
three options:
1. Keep the narrow flag with @AaronBallman's two diagnostics
2. Drop the flag and land only a hard ceiling near the allocation limit as a
pure crash fix
3. Park this and prototype a sparse or filler representation for leading zeros,
which is @erichkeane's idea
Which would you prefer?
https://github.com/llvm/llvm-project/pull/205503
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits