Details
-
Task
-
Resolution: Done
-
P2: Important
-
None
-
6.0.0
-
None
Description
I have code like this:
struct Something { char name[8]; }; Something mappings[] { { "123" }, { "1234567" }, }; // ... bool checkThing(const QByteArray &str) { for (const auto &mapping : mappings) { // mapping.name gets converted to a QByteArrayView if (str.compare(mapping.name, Qt::CaseInsensitive) == 0) return true; } return false; } // ... checkThing("123"); // Always returns false because the QByteArrayView is larger checkThing("1234567");
Which unfortunately fails after the merge / port to QByteArrayView due to it taking the size of the array minus 1. So even if I only use 3 of the characters it will still be comparing as if it was 7. While my code isn't in use anywhere so nothing is affected right now I'm sure someone else is not so lucky.
Attachments
For Gerrit Dashboard: QTBUG-85815 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
309111,7 | Document the changed semantics when passing arrays to QByteArray methods | dev | qt/qtbase | Status: MERGED | +2 | 0 |