[llvm] [DWARFLinkerParallel] Fix member initialization order (PR #81179)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 18 21:22:06 PST 2024
MaskRay wrote:
> I was concerned there might be missing test coverage here - but looks like the issue is benign (apart from the GCC warning itself) as the member is only stored as a reference and not used until after it's constructed.
>
> Looking at Clang and GCC's behavior for the warning:
>
> [godbolt.org/z/G7ndsTv5c](https://godbolt.org/z/G7ndsTv5c)
>
> It looks like GCC might have some quirks (it only warns about this case (escaping a reference to a member before the member is initialized) by the looks of it, if the ctor has only 1 parameter?).
>
> Perhaps we should disable GCC's warning and rely on Clang's more conservative interpretation?
>
> (though I don't actually object to this particular change - I think it's clearer/less subtle/etc - but in terms of what's worth filing bugs, etc about)
Interesting. I did not realize that there's a clang-vs-GCC difference and the Clang behavior suppressing the diagnostic for a reference is intentional (seems around 2014).
(It seems that Clang's conservative behavior misses certain cases, e.g.
https://github.com/llvm/llvm-project/blob/2ed0aacf973d628d5abae79229e251e034831dd3/clang/test/SemaCXX/constructor-initializer.cpp#L159)
Suppressing `-Wuninitialized` for GCC sounds good.
Filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113987 ("Binding a reference to an uninitialized data member should not cause -Wuninitialized")
https://github.com/llvm/llvm-project/pull/81179
More information about the llvm-commits
mailing list