
I found and reported the bool FFI miscompilation. The behaviour I was observing was very confusing, and I’m generally extremely hesitant to blame the compiler. Eventually I brought the problem to the rest of the team and started with “I’m running into some strange behaviour, which is smelling like a compiler bug.” somewhat reassuring that my suspicions did turn out to be correct in this case.
score 3 · canonical

The initially observed issue was failing tests in our test suite. As I traced that through I eventually landed on a Rust function that returned a
boolto Mercury code. Logging the value on the Rust side was fine, but then attempting to log the same value on the Mercury side was crashing the Mercury runtime. Eventually I logged the value from a Cforeign_procin Mercury and was seeing it was receiving the value 16 instead of 0 or 1. It was at this point that I suspected a compiler bug. Comparing the assembly of the function was also suspect:1.99: Disassembly of section .text.fontcode_rust_font_has_glyf: 0000000000000000 <fontcode_rust_font_has_glyf>: 0: 0f b6 87 9f 01 00 00 movzbl 0x19f(%rdi), %eax 7: c3 retq 1.83: Disassembly of section .text.fontcode_rust_font_has_glyf: 0000000000000000 <fontcode_rust_font_has_glyf>: 0: 0f b6 87 9f 01 00 00 movzbl 0x19f(%rdi), %eax 7: 24 01 andb $0x1, %al 9: c3 retqFrom there I was able to build a small reproducer and open an issue on the rust repo.
score 1 · canonical