Skip to content

ICE using literal bytes #2161

Description

@niooss-ledger

Hello,

This Rust program triggers an internal compiler error (ICE) when using Creusot:

use creusot_std::prelude::*;

pub fn use_bytes() -> u8 {
    b"A"[0]
}

cargo creusot reports:

thread 'rustc' (65308) panicked at creusot/src/backend/term.rs:546:43:
not yet implemented

and there indeed is a todo!() in

Literal::Bytes(ref _bytes) => todo!(),

Using the array notation works (cargo creusot succeeds and manages to proves everything):

use creusot_std::prelude::*;

const A: &[u8] = &[b'A']; // Using b"A" here triggers the ICE

#[ensures(result@ == 0x41)]
pub fn use_bytes() -> u8 {
    A[0]
}

(For context, I stumbled upon this while trying to add contracts to crate hex, which uses:

const HEX_CHARS_LOWER: &[u8; 16] = b"0123456789abcdef";

)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions