Izaron added a comment.
How the bug was working on this example:
void foo() {}
[[gnu::target("default")]] void foo() {}
[[gnu::target("avx2")]] void foo() {}
1. Clang parses the definition of the `foo` function (line 1)
2. When parsing the second definition (line 2), Clang will delete `TargetAttr`
in this function
<https://github.com/llvm/llvm-project/blob/b51c6130efac2afd183ad71b81c16c713c10a1b5/clang/lib/Sema/SemaDecl.cpp#L2933>
3. Eventually Clang will mark both `foo`s as invalid.
4. When parsing the third definition (line 3), in the
`CheckMultiVersionAdditionalDecl` method Clang is trying to compare
`TargetAttr` of the 2nd and the 3rd `foo`: link
<https://github.com/llvm/llvm-project/blob/b51c6130efac2afd183ad71b81c16c713c10a1b5/clang/lib/Sema/SemaDecl.cpp#L11100-L11101>.
5. The `CurTA` variable is equal to `nullptr` (because we deleted the attribute
in the second step), so there is undefined behaviour.
I suggest to stop looking to invalid declarations.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133641/new/
https://reviews.llvm.org/D133641
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits