https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69905

andreas.molzer at gmx dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andreas.molzer at gmx dot de

--- Comment #7 from andreas.molzer at gmx dot de ---
Leaving out the overload for operator""s(long double) will silently break valid
code. Consider:

#include <chrono>
int main() {
    using std::chrono_literals;
    auto time = operator""s(0x8000'0000'0000'0000'0000'0000ULL);
}

According to standard, this should select the overload with unsigned long long
argument, which does not exist.  It will instead silently perform a numeric
conversion to long double, resulting in loss of accuracy on targets where gcc
does not use extended 80-bit double.  Any other integer arguments, which should
lead to overload resolution failure, will also be double durations albeit with
less immediately catastrophic results. 

However, that doesn't mean the long term effects are no issue.  Consider that
the type of time.count() also unexpectedly resolves as long double.  Or even
worse that assigning decltype(time)::max() to unsigned long long is undefined
behaviour.

It might be more fitting to open the missing declarations as a separately
tracked bug, improving visibility of the standard issue as well.

Reply via email to