#Works on debug, but not on release

29 messages · Page 1 of 1 (latest)

knotty anvil
#

encoding is running on proc macro

#

and in proc macro is assert

#

assert works

abstract talon
#

Can you post the code and full errors here?

wild fern
#

Your bitshifts (>> <<) will lose information, so your message will only be decodable if the key happens to be 0

abstract talon
#

I can't say anything before seeing the code.

#

As text, please. All of it that's needed to reproduce the issue.

#

Throw it on the playground if possible.

wild fern
#

Multiplication and division also lose information. What's the value of the key in debug and release (try printing it)?

#

?eval mode=release ```rust
#![allow(arithmetic_overflow)]
let byte = 100_u8;
byte * 23 / 23

patent pecanBOT
#
     Running `target/release/playground`

10
#
     Running `target/debug/playground`
thread 'main' panicked at 'attempt to multiply with overflow', src/main.rs:4:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
wild fern
#

The problem is most likely not running in release, but the random key being different in debug and release

#

Oh wait, I misread the code, i didn't see the as usize part

#

Then there's absolutely nothing in the code you posted that could be different in release, which means that the error is somewhere else

abstract talon
#

Why are we guessing?

#

I just want to see the code.

#

make a playground link with all the code needed to reproduce the issue

wild fern
#

The playground doesn't support defining your own procedural macros. Replace rand!() with the value it produces when compiled instead

#

If the issue goes away, then it was a problem with the procedural macro

#

Does the procedural macro create a random number? If so, then that is probably causing the problem. rustc expects procedural macros to produce the same value each time (given the same arguments), and making it produce different values could possibly make the value of KEY different in different places of the code (because of the caching from incremental compilation)

#

Replace the rand!() call with a number (like 12) and see if it works in debug and release

knotty anvil
#

output is in usize

wild fern
#

I highly recommend against compile time random numbers. They end up breaking things in all sorts of ways. Changing the const to a static might help but apart from that I can't help you

knotty anvil
wild fern
wild fern
knotty anvil
#

ok

wild fern
#

Then I'm out of ideas