I have a without @1 :Text;
field in a message which is (intentionally) not initialised. The result of calling get_without()
on the reader for this message varies based on compile settings. This is not ideal.
With --release
and lto = true
, it returns an error:
Error { kind: Failed, description: "Message contains non-list pointer where text was expected." }
On all other configurations, including --release
without lto = true
, and non-release, it returns the empty string.
This is, um, not expected.
- Is there any intentional variation in
capnproto-rust
, or is this arguably a compiler bug?
- What's the expected output? Should
get_
error for missing fields?
- What does the error mean?
I've made a sample project, which will demonstrate the problem with cargo run --release
. The other cases can be tested with cargo run
and by #commenting
lto = true
in Cargo.toml
, and cargo run --release
. It's a binary (which does nothing on success) as it doesn't seem to fail in cargo test --release
; didn't look why.
git clone https://github.com/FauxFaux/capnp-get-null
cd capnp-get-null
RUST_BACKTRACE=1 cargo run --release
Finished release [optimized + debuginfo] target(s) in 0.0 secs
Running `target/release/capnp-get-null`
thread 'main' panicked at 'without: Error { kind: Failed, description: "Message contains non-list pointer where text was expected." }', /checkout/src/libcore/result.rs:906:4
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
...
6: core::result::unwrap_failed
at /checkout/src/libcore/macros.rs:41
7: capnp_get_null::main
at /checkout/src/libcore/result.rs:799
at src/main.rs:28
at src/main.rs:35
8: main
9: __libc_start_main
10: _start
The code which errors is at: main.rs:28
The schema is totally trivial:
@0xbc035dbe0d877227;
struct Foo {
with @0 :Text;
without @1 :Text;
}
Tested on Ubuntu 17.10 (Artful) amd64 with rustc 1.21.0 (3b72af97e 2017-10-09)
(stable) and rustc 1.23.0-nightly (8b22e70b2 2017-10-31)
.