summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-27 13:15:18 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-02-12 12:39:52 +0100
commitc8e03f129ea52ddc8e15104d5441328f6c90647f (patch)
tree3d6fc8e018245e6a36b5d83293d09e5ae7a42afc /src/corelib/tools
parentb5c4d1f50b1e2d44fbb3535ebedc565525ecc64f (diff)
QHashSeed: remove 'pure' attribute on globalSeed()
While 'pure' in GCC is weaker than Stepanov's Regular Procedure from Elements of Programming (equal result for equal inputs), it does not allow accesses to volatile memory: > functions declared with the pure attribute can safely read any > non-volatile objects The globalSeed() function reads from an atomic variable that can be changed at any time from another thread. Atomics, while not volatile objects in the sense of the keyword, must fall under the pure attribute doc's exclusion criterion: The difference between a volatile and an atomic access, while important for the implementation of the function, is indistinguishable to the caller of the function: both volatile and atomic objects can change value without the current thread of execution changing them, with no way for the caller of the function to distinguish which one occurred. Therefore, globalSeed() should not be pure. 5.15 is not affected, as qGlobalQHashSeed() is not marked as pure. Task-number: QTBUG-62185 Pick-to: 6.3 6.2 Change-Id: I6fc52e2bd41ef4aa3f8039072b47c7a1314b98fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qhashfunctions.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h
index 4d0b2d9519..a3e1600600 100644
--- a/src/corelib/tools/qhashfunctions.h
+++ b/src/corelib/tools/qhashfunctions.h
@@ -76,7 +76,7 @@ struct QHashSeed
constexpr QHashSeed(size_t d = 0) : data(d) {}
constexpr operator size_t() const noexcept { return data; }
- static Q_CORE_EXPORT QHashSeed globalSeed() noexcept Q_DECL_PURE_FUNCTION;
+ static Q_CORE_EXPORT QHashSeed globalSeed() noexcept;
static Q_CORE_EXPORT void setDeterministicGlobalSeed();
static Q_CORE_EXPORT void resetRandomGlobalSeed();
private: