Похожие чаты

Got another almost impossible exercise I'll simplify a bit so

if long long a[3] = {3, 65535, 65536} and short int *q = (short*) a

why (*(q+9)-q[0]) == -2 is true?

5 ответов

9 просмотров

should be UB, Assuming sizeof(short int) == 2 and sizeof(long) == 8) you might have an short int array that looks like this short int b[] = { 3, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0 }; doing b[9] - b[0] yields -2

that is undefined behavior

Assuming if the sizeof long is always 8 and the sizeof short is always 2 and the endianess is always little-endian in such an environment, passing -fno-strict-aliasing flag will make it well-defined behavior.

Mmmmm.....
Assuming if the sizeof long is always 8 and the si...

the language does not define -fno-strict-aliasing, hence it is still UB according to the standard.

olli
the language does not define -fno-strict-aliasing,...

Yeah, it is actually a compiler feature to deactivate strict aliasing.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта