-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingchronoC++20 chronoC++20 chronofixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomers
Description
Bug description
The message of ambiguous_local_time
exception class should be (per [time.zone.exception.ambig]/4):
Effects: Initializes the base class with a sequence of
char
equivalent to that produced byos.str()
initialized as shown below:ostringstream os; os << tp << " is ambiguous. It could be\n" << tp << ' ' << i.first.abbrev << " == " << tp - i.first.offset << " UTC or\n" << tp << ' ' << i.second.abbrev << " == " << tp - i.second.offset << " UTC";
Repro:
#include <cassert>
#include <chrono>
#include <iostream>
#include <string>
int main() {
const std::string_view required_start =
"2016-11-06 01:30:00 is ambiguous. It could be";
// Example 1, [time.zone.exception.ambig]/4
using namespace std::chrono;
try {
auto zt = zoned_time{"America/New_York",
local_days{Sunday[1] / November / 2016} + 1h + 30min};
} catch (const ambiguous_local_time &e) {
std::cout << e.what() << '\n';
assert(std::string_view{e.what()}.starts_with(required_start));
}
}
Build:
PS D:\stl-playground> clang -std=c++20 .\test.cpp
PS D:\stl-playground> .\a.exe
2016-11-06 01:30:00 is ambiguous. It could be
2016-11-06 01:30:00 GMT-4 == 2016-11-06 05:30:00 UTC or
2016-11-06 01:30:00 GMT-5 == 2016-11-06 06:30:00 UTC
Assertion failed: std::string_view{e.what()}.starts_with(required_start), file .\test.cpp, line 17
Summary:
- There is one extra space (
0x20
) missing between "ambiguous." and "It", - Compiler explorer (GCC): https://godbolt.org/z/E36xP4x3z.
"Good first issue" tips
It should say is ambiguous. It could be
(two spaces) in those places:
Line 6014 in e6a12f7
_Os << _Tp << " is ambiguous. It could be\n" == "2016-11-06 01:30:00 is ambiguous. It could be\n" == "2016-11-06 01:30:00 is ambiguous. It could be\n"
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingchronoC++20 chronoC++20 chronofixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomers