nathanchance wrote:

> This case might be reasonable to handle differently, but I'm on the fence 
> too. There's two cases for structure members, broadly:
> 
> 1) Don't initialize the `const` field, don't ever read the `const` field.
> 
> 2) Rely on the fact that you can overwrite a `const` if the top-level object 
> was not declared `const`.

Yes, this appears to be the case for the 10 or so unique cases that I found in 
the kernel.

> In both cases, the code is valid and so the warning is a false positive. In 
> both cases, the code is dangerous and the warning is useful. So I kind of 
> think this is a case where we split the field diagnostic out into its own 
> group. So we'd have `-Wdefault-const-init-field` which covers field 
> initialization cases, and it would be grouped under `-Wdefault-const-init` 
> which covers both fields and variables. WDYT?

Yes, that seems like a reasonable place to start. I would be happy to test such 
a change.



https://github.com/llvm/llvm-project/pull/137166
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to