This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix single-element array initialization in constexpr
ClosedPublic

Authored by Fznamznon on Mar 7 2023, 4:11 AM.

Details

Summary

https://reviews.llvm.org/D130791 added an improvement that in case array
element has a trivial constructor, it is evaluated once and the result is
re-used for remaining elements. Make sure the constructor is evaluated
for single-elements arrays too.

Fixes https://github.com/llvm/llvm-project/issues/60803

Diff Detail

Event Timeline

Fznamznon created this revision.Mar 7 2023, 4:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2023, 4:11 AM
Fznamznon requested review of this revision.Mar 7 2023, 4:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2023, 4:11 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Fznamznon updated this revision to Diff 502992.Mar 7 2023, 4:50 AM

Check FinalSize instead of N since it is probably more obvious

aaron.ballman accepted this revision.Mar 7 2023, 5:35 AM

LGTM, thank you for this! Please be sure to file an issue to backport this to the 16.x branch (https://llvm.org/docs/GitHub.html#backporting-fixes-to-the-release-branches).

clang/test/SemaCXX/constexpr-single-element-array.cpp
4–7

Minor rewording and removing the extra / in the comment.

This revision is now accepted and ready to land.Mar 7 2023, 5:35 AM
Fznamznon updated this revision to Diff 503020.Mar 7 2023, 6:13 AM

Rebase and update test comment.