Error on initializing QByteArray
-
Hi,
I am porting an app from Qt 5.12.2 to Qt 6.5.0
The following lines are generating a crash in Qt6 while they posed no problem in Qt5QByteArray qb; qb[0] = 0; qb[1] = 0;
I have not found any indication in the documentation of the QByteArray class that its behaviour had been modified regarding this.
Any idea ?
-
Hi,
It's explained in the operator documentation for Qt 5.15. And the behavior for Qt 6 is also explained in the corresponding operator documentation.
Your code
willmight already crash with 5.15. -
Hi SGaist
Thanks for your help. Believe me, this code is working in 5.15.2 every day.
I'll read the doc carefully -
@oliver_mpt said in Error on initializing QByteArray:
Believe me, this code is working in 5.15.2 every day.
But it may crash tomorrow since it's undefined behavior.
-
@oliver_mpt my bad, wrong verb. I meant to write: might already crash. But luckily it's not.
In any case, as the warning suggests, do not rely on such a behaviour.
-
Thanks SGaist and Christian
I'll rewrite that code cleanly :-) -
You're welcome !
Since you have the information you need, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum members may know a solution has been found :-)