<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96820>96820</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Cannot format a duration with unsigned (or user-defined) representation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dangelog
</td>
</tr>
</table>
<pre>
Testcase: https://godbolt.org/z/EM7WxfEfT
```
#include <chrono>
#include <format>
int main()
{
(void)
std::format("{}", std::chrono::duration<unsigned>{});
}
```
Does not build:
```
In file included from /opt/compiler-explorer/clang-trunk-20240626/bin/../include/c++/v1/chrono:952:
/opt/compiler-explorer/clang-trunk-20240626/bin/../include/c++/v1/__chrono/formatter.h:594:63: error: no matching function for call to 'abs'
594 | __formatter::__format_chrono_using_chrono_specs(__sstr, chrono::abs(__value), __chrono_specs);
| ^~~~~~~~~~~
```
`chrono::abs` is constrained for durations whose representation type is signed. This excludes unsigned types as well as any user-defined representation type.
Matching bug in libstdc++: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115668
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2PozgQ_TXFpRREbD7CgUM6aaQ9zG2kPSJjG_CuY0e2SbrnsL99ZQKdmd7evS1Cxna5qp7rPYp5r0YjZQPFCxTnhM1hsq4RzIxS2zHprXhvvksfOPMS6BGnEK4e6BFIC6QdreitDql1I5D2B5D29Vv1-9vwOnyH7AzZcR3LbH0fS0KV4XoWEoGe-OSssUBfvzIO1l1YeBqXUZmAF6YMkAOQerVUL48JIiKQw80q8WHE9fFBROj0uIaN_iR6Vuc4IafniQ1VnIvZsaCsAXqazVIvERGtfjXQlw3D-ev7LuPZSo_GBuxnpZcs_16h3wwOSktcKyFwcPaCQFp7DUBabi9XpaXbybertk66uKeZGXfBzebPHclInpWkBNL2sUxtmgJp12DxLJCX5W1v-7jc7loX5Inrf0rWdWs60j5YCNKlE9BjUedAjyWNKpPOWRcnxuKFBT4pM-IwGx5pwME65ExrDBaBVKz3QKqN6aLOEaoTdt1H-AeL28aav5u9MuO28FfJPZBD13kfXFTCzwJYMhy67sb0LCPjJMb_1fUpg4fWIgYoXv_6eP5DGlBmn9OVGSqP3BofHFMmSsA63JTo8T5ZL9HJq5NemrDsYni_yuj20GiK3yflUb4tTHjctLsc88g83qXW8cvMO85eup2Qw5Lri7jpz4C_bZz084jKoFa9D2Jj-p9tgvN0NPPaJvp5_KG0ZkBaP9l7189jykcFtFUC6Hm_L8rykIiGiprWLJHNvtrXOS0PZZlMTZYVdU8HymmWsyw7FDzPxZ7yqhJEiD1NVLMpkuzJPivTjBd1XtG6GLgsiRggz-SFKZ1qfbtETInyfpZNXR5IlmjWS-2XfkiIkXdcjLE9FOfENdFn18-jhzzTygf_jBJU0LI5MRN_8ofWkH1QhncVpicHQA7W_VJ0IPWnuiez082nSqowzX3K7QVIGzOvn93V2T8kj__rgtcDaR_3uTXk7wAAAP__iMnO-A">