Closed
Description
For some reason, comparing to identical arrays does not yield true
in all cases.
I tried this code:
#![no_std]
#![no_main]
extern crate panic_halt;
use arduino_uno::prelude::*;
#[arduino_uno::entry]
fn main() -> ! {
let peripherals = arduino_uno::Peripherals::take().unwrap();
let mut pins = arduino_uno::Pins::new(
peripherals.PORTB,
peripherals.PORTC,
peripherals.PORTD,
);
let mut serial = arduino_uno::Serial::new(
peripherals.USART0,
pins.d0,
pins.d1.into_output(&mut pins.ddr),
57600,
);
let a = [ true, true, true, true, true ];
let b = a;
ufmt::uwriteln!(&mut serial, "{}\r", a == b).void_unwrap(); // prints false
let a = [ true, true, true, true ];
let b = a;
ufmt::uwriteln!(&mut serial, "{}\r", a == b).void_unwrap(); // prints true
let a = [ 0, 1 ];
let b = a;
ufmt::uwriteln!(&mut serial, "{}\r", a == b).void_unwrap(); // prints false
let a = [ 0 ];
let b = a;
ufmt::uwriteln!(&mut serial, "{}\r", a == b).void_unwrap(); // prints true
loop {}
}
I expected to see this happen: all lines print true
Instead, this happened: some print false
. See the code.
Meta
rustc --version --verbose
:
rustc 1.49.0-nightly (dd7fc54eb 2020-10-15)
binary: rustc
commit-hash: dd7fc54ebdca419ad9d3ab1e9f5ed14e770768ea
commit-date: 2020-10-15
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0
I am cross compiling for the avr-unknown-unknown
target. I did not try any other targets except the host (x86_64-unknown-linux-gnu
), on which it does work.
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessTarget: AVR processors (ATtiny, ATmega, etc.)Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.
Activity