Telegram Group & Telegram Channel
Копался в случайных issues на гитхабе и нашел интересное обсуждение:
https://github.com/rust-lang/rust/issues/28728

TLDR:
Раст ловил ошибки в бесконечных циклах из-за того, что LLVM привык выкидывать такие циклы в плюсах.

Чуть более развернуто:

Компилятор C++ в некоторых случаях может выбрасывать бесконечные циклы. Все к этому привыкли и пугают детей вот такими примерами с УБ: https://godbolt.org/z/KKa34Mjar.

Но в программах на Rust не бывает УБ*, бесконечные циклы разрешены и поэтому примеры с УБ (раз) (два) пугают уже не только детей.

Ошибки выше обусловлены тем, что LLVM, которым компилируется и Rust, и C++, выбрасывал бесконечные циклы, так как считал, что выполнение программы должно к чему-то приводить.

Проблема в итоге починилась в 2021 году спустя 6 лет после обнаружения в расте и спустя 15! лет после обнаружения в си. Решением стало добавление атрибута mustprogress в LLVM IR для циклов в языках с forward progress guarantee.

Интересно, кстати, что в расте предлагалось добавлять

unsafe {asm!("" :::: "volatile")}

к циклам, чтобы создать side effect, запрещающий компилятору выбрасывать бесконечные циклы.

Мораль:
Ты можешь быть бесконечно без УБ, но какой в этом толк, если твой программист плачет

P.S.
Еще всякие рандомные ссылки, которые я нашел, пока разбирался:

1. Forward progress guarantees: Base definitions
2. Why undefined behavior for infinite loops
3. The as-if rule
4. C Compilers Disprove Fermat’s Last Theorem
5. Trivial infinite loops are not Undefined Behavior



group-telegram.com/misha_writes_code/210
Create:
Last Update:

Копался в случайных issues на гитхабе и нашел интересное обсуждение:
https://github.com/rust-lang/rust/issues/28728

TLDR:
Раст ловил ошибки в бесконечных циклах из-за того, что LLVM привык выкидывать такие циклы в плюсах.

Чуть более развернуто:

Компилятор C++ в некоторых случаях может выбрасывать бесконечные циклы. Все к этому привыкли и пугают детей вот такими примерами с УБ: https://godbolt.org/z/KKa34Mjar.

Но в программах на Rust не бывает УБ*, бесконечные циклы разрешены и поэтому примеры с УБ (раз) (два) пугают уже не только детей.

Ошибки выше обусловлены тем, что LLVM, которым компилируется и Rust, и C++, выбрасывал бесконечные циклы, так как считал, что выполнение программы должно к чему-то приводить.

Проблема в итоге починилась в 2021 году спустя 6 лет после обнаружения в расте и спустя 15! лет после обнаружения в си. Решением стало добавление атрибута mustprogress в LLVM IR для циклов в языках с forward progress guarantee.

Интересно, кстати, что в расте предлагалось добавлять


unsafe {asm!("" :::: "volatile")}

к циклам, чтобы создать side effect, запрещающий компилятору выбрасывать бесконечные циклы.

Мораль:
Ты можешь быть бесконечно без УБ, но какой в этом толк, если твой программист плачет

P.S.
Еще всякие рандомные ссылки, которые я нашел, пока разбирался:

1. Forward progress guarantees: Base definitions
2. Why undefined behavior for infinite loops
3. The as-if rule
4. C Compilers Disprove Fermat’s Last Theorem
5. Trivial infinite loops are not Undefined Behavior

BY Миша пишет код


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/misha_writes_code/210

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

"We're seeing really dramatic moves, and it's all really tied to Ukraine right now, and in a secondary way, in terms of interest rates," Octavio Marenzi, CEO of Opimas, told Yahoo Finance Live on Thursday. "This war in Ukraine is going to give the Fed the ammunition, the cover that it needs, to not raise interest rates too quickly. And I think Jay Powell is a very tepid sort of inflation fighter and he's not going to do as much as he needs to do to get that under control. And this seems like an excuse to kick the can further down the road still and not do too much too soon." One thing that Telegram now offers to all users is the ability to “disappear” messages or set remote deletion deadlines. That enables users to have much more control over how long people can access what you’re sending them. Given that Russian law enforcement officials are reportedly (via Insider) stopping people in the street and demanding to read their text messages, this could be vital to protect individuals from reprisals. Pavel Durov, a billionaire who embraces an all-black wardrobe and is often compared to the character Neo from "the Matrix," funds Telegram through his personal wealth and debt financing. And despite being one of the world's most popular tech companies, Telegram reportedly has only about 30 employees who defer to Durov for most major decisions about the platform. Just days after Russia invaded Ukraine, Durov wrote that Telegram was "increasingly becoming a source of unverified information," and he worried about the app being used to "incite ethnic hatred." Oh no. There’s a certain degree of myth-making around what exactly went on, so take everything that follows lightly. Telegram was originally launched as a side project by the Durov brothers, with Nikolai handling the coding and Pavel as CEO, while both were at VK.
from ye


Telegram Миша пишет код
FROM American