[Development] Unnecessary ambiguity in Qt documentation about reentrancy and safety of const methods.

Kai Köhne Kai.Koehne at qt.io
Mon Jul 20 14:33:04 CEST 2026


Hi,

Great discussion! I took the liberty to distill the summary - as I understand it - into a task: https://qt-project.atlassian.net/browse/QTBUG-148455 .

Regards

Kai



Confidential

From: Development <development-bounces at qt-project.org> on behalf of Giuseppe D'Angelo via Development <development at qt-project.org>
Date: Sunday, 19. July 2026 at 01:07
To: NIkolai Marchenko <enmarantispam at gmail.com>
Cc: development at qt-project.org <development at qt-project.org>
Subject: Re: [Development] Unnecessary ambiguity in Qt documentation about reentrancy and safety of const methods.

On 19/07/2026 00:38, NIkolai Marchenko wrote:
> I am not exactly sure if your wording covers the
> qlocale::toDouble(string,bool&) or not.  aka non const but also
> partially not same data.


Well, the signature is

> double QLocale::toDouble(const QString &s, bool *ok = nullptr) const

Therefore, in the extended contract, it's OK to call this function from
multiple threads, without synchronization, on the same QLocale object
and/or on the same QString object. It's not OK to call it on the same
bool object.

Without the extended contract, do note that it's formally illegal to
call this function on the same QString instance, even if called on
different QLocale instances. toDouble() could call something like
`s.utf16()` internally, which isn't thread-safe.

My 2 c,
--
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kdab.com%2F&data=05%7C02%7C%7Cd6b7f3f02a32467c0a0308dee52154d5%7C20d0b167794d448a9d01aaeccc1124ac%7C0%7C0%7C639200128549034191%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=vtj%2FV417QBwz670zwxDbY3NjEwNfFr89KyGfTU7qDSg%3D&reserved=0<http://www.kdab.com/>
KDAB - Trusted Software Excellence
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20260720/fb92fc18/attachment.htm>


More information about the Development mailing list