#Rust: “note: the compiler unexpectedly panicked. this is a bug.” 😬

@rauschma Uh-oh. I'm curious the context on this one.

@mtomczak Apparently the compiler doesn’t like my code. Don’t know why.

@rauschma Sorry to hear it. I've been keeping an eye on Rust as a possible replacement for C++ in some tasks I'm responsible for, but "Sometimes the compiler just panics" is going to be a real hard sell to my teammates.

@mtomczak @rauschma I've not really seen internal compiler errors except when doing rather strange things. Not sure what the issue here.

If C++ compilers do this less, that may be due to having fewer runtime checks (at least in release builds), and undefined behavior instead of panics.

@ids1024 @rauschma That's hard to quantify, but I think it's a really good way to think about it and definitely worth putting in my slide deck. "I'd rather have the compiler panic than have the compiler generate code that just wilds into unallocated memory."

@mtomczak @rauschma I know in LLVM this is a bit of an issue with `llvm_unreachable`, which is undefined behavior if reached in release mode, and is a bit overused: discourse.llvm.org/t/llvm-unre

Though in LLVM codegen that applies to Rust too. But LLVM added an option to make this trap instead of undefined behavior, and when I saw that I opened a PR to Rust to enable it: github.com/rust-lang/rust/pull

@mtomczak I've only personally seen this with an experimental LLVM backend (m68k), so I don't know how much this or other similar things are a problem in practice.

But it does seem to show something about Rust vs. C++ development philosophy (favoring panics over undefined behavior, for cases that shouldn't happen but aren't statically guaranteed not to), including in how the compiler itself is developed.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.