Skip to content

Fix incorrect use of reinterpret_cast#30301

Open
safocl wants to merge 3 commits intotelegramdesktop:devfrom
safocl:fix-reinterpret-cast
Open

Fix incorrect use of reinterpret_cast#30301
safocl wants to merge 3 commits intotelegramdesktop:devfrom
safocl:fix-reinterpret-cast

Conversation

@safocl
Copy link
Copy Markdown

@safocl safocl commented Feb 17, 2026

Using reinterpret_cast from string (array of chars) (?) to uint32, uint64, uint16 is undefined behavior (program attempts to access the stored value of an object through a glvalue through which it is not type-accessible).
https://eel.is/c++draft/basic.lval#11

11 An object of dynamic type Tobj is type-accessible through a glvalue of type Tref if Tref is similar ([conv.qual]) to:
(11.1) -- Tobj,
(11.2) -- a type that is the signed or unsigned type corresponding to Tobj, or
(11.3) -- a char, unsigned char, or std​::​byte type.

If a program attempts to access ([defns.access]) the stored value of an object through a glvalue through which it is not type-accessible, the behavior is undefined.38

fix for #30300

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 17, 2026

CLA assistant check
All committers have signed the CLA.

For general-purpose storage, only the types “array of N unsigned char” or “array of N std::byte” are allowed.
https://eel.is/c++draft/intro.object#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants