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

The last couple days have exemplified that uncertainty. On Thursday, news emerged that talks in Turkey between the Russia and Ukraine yielded no positive result. But on Friday, Reuters reported that Russian President Vladimir Putin said there had been some “positive shifts” in talks between the two sides. You may recall that, back when Facebook started changing WhatsApp’s terms of service, a number of news outlets reported on, and even recommended, switching to Telegram. Pavel Durov even said that users should delete WhatsApp “unless you are cool with all of your photos and messages becoming public one day.” But Telegram can’t be described as a more-secure version of WhatsApp. Ukrainian forces have since put up a strong resistance to the Russian troops amid the war that has left hundreds of Ukrainian civilians, including children, dead, according to the United Nations. Ukrainian and international officials have accused Russia of targeting civilian populations with shelling and bombardments. If you initiate a Secret Chat, however, then these communications are end-to-end encrypted and are tied to the device you are using. That means it’s less convenient to access them across multiple platforms, but you are at far less risk of snooping. Back in the day, Secret Chats received some praise from the EFF, but the fact that its standard system isn’t as secure earned it some criticism. If you’re looking for something that is considered more reliable by privacy advocates, then Signal is the EFF’s preferred platform, although that too is not without some caveats. The company maintains that it cannot act against individual or group chats, which are “private amongst their participants,” but it will respond to requests in relation to sticker sets, channels and bots which are publicly available. During the invasion of Ukraine, Pavel Durov has wrestled with this issue a lot more prominently than he has before. Channels like Donbass Insider and Bellum Acta, as reported by Foreign Policy, started pumping out pro-Russian propaganda as the invasion began. So much so that the Ukrainian National Security and Defense Council issued a statement labeling which accounts are Russian-backed. Ukrainian officials, in potential violation of the Geneva Convention, have shared imagery of dead and captured Russian soldiers on the platform.
from ms


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