From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DFCA13858D35; Thu, 7 Mar 2024 00:37:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFCA13858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709771845; bh=D3u0Xivl/BGzhNemD/ojKGOu8UAbuHKYhlLB9ApaK4w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L0jZaLduM5EQ+WADC7aupFmhZ5DgzLcGUCTeW9kdRO8BZcU7pkxh/RrSn/7S90NhU iCbV6tkDzWDEGiQJZDyXj9HWskny0qvBDhzS9GsU932mrOXpyX9C2X+XItJGKrCePj o36UrPglmLX9RrNUb2Z+6FmLp4BX6YhbOO7T/Tb4= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114244] Need to use round when parsing fractional seconds Date: Thu, 07 Mar 2024 00:37:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114244 --- Comment #3 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #1) > Yup, the seconds part "00.002" is parsed using std::numpunct (in order to Oops, std::num_get obviously. > handle the locale's decimal point) and then converted to milliseconds usi= ng > duration_cast: >=20 > auto& __ng =3D use_facet>(__loc); > long double __val; > ios_base::iostate __err2{}; > __ng.get(__buf, {}, __buf, __err2, __val); > if (__is_failed(__err2)) [[unlikely]] > __err |=3D __err2; > else > { > duration __fs(__val); > __s =3D duration_cast<_Duration>(__fs); > } As an unrelated optimization, when the locale is "C" we could use std::from_chars or std::stod instead of std::num_get.=