Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Error on initializing QByteArray
QtWS: Super Early Bird Tickets Available!

Error on initializing QByteArray

Scheduled Pinned Locked Moved Unsolved Qt 6
7 Posts 3 Posters 376 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oliver_mpt
    wrote on 15 May 2023, 19:08 last edited by
    #1

    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 Qt5

    QByteArray 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 ?

    S 1 Reply Last reply 15 May 2023, 19:16
    0
  • S Offline
    S Offline
    SGaist Lifetime Qt Champion
    replied to oliver_mpt on 15 May 2023, 19:16 last edited by SGaist
    #2

    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 will might already crash with 5.15.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
  • O Offline
    O Offline
    oliver_mpt
    wrote on 15 May 2023, 19:22 last edited by
    #3

    Hi SGaist

    Thanks for your help. Believe me, this code is working in 5.15.2 every day.
    I'll read the doc carefully

    C S 2 Replies Last reply 15 May 2023, 19:22
    0
  • C Online
    C Online
    Christian Ehrlicher Lifetime Qt Champion
    replied to oliver_mpt on 15 May 2023, 19:22 last edited by
    #4

    @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.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    0
  • S Offline
    S Offline
    SGaist Lifetime Qt Champion
    replied to oliver_mpt on 15 May 2023, 19:25 last edited by
    #5

    @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.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
  • O Offline
    O Offline
    oliver_mpt
    wrote on 15 May 2023, 19:31 last edited by
    #6

    Thanks SGaist and Christian
    I'll rewrite that code cleanly :-)

    S 1 Reply Last reply 15 May 2023, 19:44
    0
  • S Offline
    S Offline
    SGaist Lifetime Qt Champion
    replied to oliver_mpt on 15 May 2023, 19:44 last edited by
    #7

    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 :-)

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0

6/7

15 May 2023, 19:31

1 unread
  • Login

  • Login or register to search.
6 out of 7
  • First post
    6/7
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved