================ @@ -626,29 +626,49 @@ static void __parse_leap_seconds(vector<leap_second>& __leap_seconds, istream&& // seconds since 1 January 1970. constexpr auto __offset = sys_days{1970y / January / 1} - sys_days{1900y / January / 1}; - while (true) { - switch (__input.peek()) { - case istream::traits_type::eof(): - return; - - case ' ': - case '\t': - case '\n': - __input.get(); - continue; + struct __entry { + sys_seconds __timestamp; + seconds __value; + }; + vector<__entry> __entries; + [&] { + while (true) { + switch (__input.peek()) { + case istream::traits_type::eof(): + return; + + case ' ': + case '\t': + case '\n': + __input.get(); + continue; + + case '#': + chrono::__skip_line(__input); + continue; + } - case '#': + sys_seconds __date = sys_seconds{seconds{chrono::__parse_integral(__input, false)}} - __offset; + chrono::__skip_mandatory_whitespace(__input); + seconds __value{chrono::__parse_integral(__input, false)}; chrono::__skip_line(__input); - continue; - } - sys_seconds __date = sys_seconds{seconds{chrono::__parse_integral(__input, false)}} - __offset; - chrono::__skip_mandatory_whitespace(__input); - seconds __value{chrono::__parse_integral(__input, false)}; - chrono::__skip_line(__input); - - __leap_seconds.emplace_back(std::__private_constructor_tag{}, __date, __value); - } + __entries.emplace_back(__date, __value); + } + }(); + // The Standard requires the leap seconds to be sorted. The file + // leap-seconds.list usually provides them in sorted order, but that is not + // guaranteed so we ensure it here. + std::ranges::sort(__entries, {}, &__entry::__timestamp); ---------------- ldionne wrote:
```suggestion ranges::sort(__entries, {}, &__entry::__timestamp); ``` https://github.com/llvm/llvm-project/pull/90070 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits