Skip to content

Following the tutorial produces many warning messages on cargo test #2104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fwip opened this issue Oct 5, 2021 · 6 comments · Fixed by #2203
Closed

Following the tutorial produces many warning messages on cargo test #2104

fwip opened this issue Oct 5, 2021 · 6 comments · Fixed by #2203

Comments

@fwip
Copy link

fwip commented Oct 5, 2021

This error occurs at step 5 of the tutorial: https://rust-lang.github.io/rust-bindgen/tutorial-5.html
I am on a Macbook, OS version 11.6 (big sur)

Input C/C++ Header

#include <bzlib.h>

Sorry, I know the template says "no #includes", but I'm not sure how to view the contents of this system header. If there is a specific bzip2.h file that I "should" be using for this tutorial, I am happy to try it.

Bindgen Invocation

build.rs:

extern crate bindgen;

use std::env;
use std::path::PathBuf;

fn main() {
    // Tell cargo to tell rustc to link the system bzip2
    // shared library.
    println!("cargo:rustc-link-lib=bz2");

    // Tell cargo to invalidate the built crate whenever the wrapper changes
    println!("cargo:rerun-if-changed=wrapper.h");

    // The bindgen::Builder is the main entry point
    // to bindgen, and lets you build up options for
    // the resulting bindings.
    let bindings = bindgen::Builder::default()
        // The input header we would like to generate
        // bindings for.
        .header("wrapper.h")
        // Tell cargo to invalidate the built crate whenever any of the
        // included header files changed.
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        // Finish the builder and generate the bindings.
        .generate()
        // Unwrap the Result and panic on failure.
        .expect("Unable to generate bindings");

    // Write the bindings to the $OUT_DIR/bindings.rs file.
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings!");
}

Actual Results

$ cargo test
   Compiling wxWidgets-rs v0.1.0 (/Volumes/projects/futz/wxWidgets-rs)
warning: panic message is not a string literal
  --> src/lib.rs:59:59
   |
59 |                 r if r == (BZ_PARAM_ERROR as _) => panic!(BZ_PARAM_ERROR),
   |                                                           ^^^^^^^^^^^^^^
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
59 |                 r if r == (BZ_PARAM_ERROR as _) => panic!("{}", BZ_PARAM_ERROR),
   |                                                           ^^^^^
help: or use std::panic::panic_any instead
   |
59 |                 r if r == (BZ_PARAM_ERROR as _) => std::panic::panic_any(BZ_PARAM_ERROR),
   |                                                    ^^^^^^^^^^^^^^^^^^^^^

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:239:19
    |
239 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).next_in as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed
    |
    = note: `#[warn(deref_nullptr)]` on by default

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:249:19
    |
249 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).avail_in as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:259:19
    |
259 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).total_in_lo32 as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:269:19
    |
269 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).total_in_hi32 as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:279:19
    |
279 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).next_out as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:289:19
    |
289 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).avail_out as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:299:19
    |
299 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).total_out_lo32 as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:309:19
    |
309 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).total_out_hi32 as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:319:19
    |
319 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).state as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:329:19
    |
329 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).bzalloc as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:339:19
    |
339 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).bzfree as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:349:19
    |
349 |         unsafe { &(*(::std::ptr::null::<bz_stream>())).opaque as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:389:19
    |
389 |         unsafe { &(*(::std::ptr::null::<__mbstate_t>())).__mbstate8 as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:399:19
    |
399 |         unsafe { &(*(::std::ptr::null::<__mbstate_t>()))._mbstateL as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:461:14
    |
461 |             &(*(::std::ptr::null::<__darwin_pthread_handler_rec>())).__routine as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:473:14
    |
473 |             &(*(::std::ptr::null::<__darwin_pthread_handler_rec>())).__arg as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:485:14
    |
485 |             &(*(::std::ptr::null::<__darwin_pthread_handler_rec>())).__next as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:515:19
    |
515 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_attr_t>())).__sig as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:525:19
    |
525 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_attr_t>())).__opaque as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:554:19
    |
554 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_cond_t>())).__sig as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:564:19
    |
564 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_cond_t>())).__opaque as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:594:14
    |
594 |             &(*(::std::ptr::null::<_opaque_pthread_condattr_t>())).__sig as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:606:14
    |
606 |             &(*(::std::ptr::null::<_opaque_pthread_condattr_t>())).__opaque as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:636:19
    |
636 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_mutex_t>())).__sig as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:647:14
    |
647 |             &(*(::std::ptr::null::<_opaque_pthread_mutex_t>())).__opaque as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:678:14
    |
678 |             &(*(::std::ptr::null::<_opaque_pthread_mutexattr_t>())).__sig as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:690:14
    |
690 |             &(*(::std::ptr::null::<_opaque_pthread_mutexattr_t>())).__opaque as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:720:19
    |
720 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_once_t>())).__sig as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:730:19
    |
730 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_once_t>())).__opaque as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:759:19
    |
759 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_rwlock_t>())).__sig as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:770:14
    |
770 |             &(*(::std::ptr::null::<_opaque_pthread_rwlock_t>())).__opaque as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:801:14
    |
801 |             &(*(::std::ptr::null::<_opaque_pthread_rwlockattr_t>())).__sig as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:813:14
    |
813 |             &(*(::std::ptr::null::<_opaque_pthread_rwlockattr_t>())).__opaque as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:844:19
    |
844 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_t>())).__sig as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:855:14
    |
855 |             &(*(::std::ptr::null::<_opaque_pthread_t>())).__cleanup_stack as *const _ as usize
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:866:19
    |
866 |         unsafe { &(*(::std::ptr::null::<_opaque_pthread_t>())).__opaque as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:948:19
    |
948 |         unsafe { &(*(::std::ptr::null::<__sbuf>()))._base as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
   --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:958:19
    |
958 |         unsafe { &(*(::std::ptr::null::<__sbuf>()))._size as *const _ as usize },
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1030:19
     |
1030 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._p as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1040:19
     |
1040 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._r as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1050:19
     |
1050 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._w as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1060:19
     |
1060 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._flags as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1070:19
     |
1070 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._file as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1080:19
     |
1080 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._bf as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1090:19
     |
1090 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._lbfsize as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1100:19
     |
1100 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._cookie as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1110:19
     |
1110 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._close as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1120:19
     |
1120 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._read as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1130:19
     |
1130 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._seek as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1140:19
     |
1140 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._write as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1150:19
     |
1150 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._ub as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1160:19
     |
1160 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._extra as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1170:19
     |
1170 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._ur as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1180:19
     |
1180 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._ubuf as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1190:19
     |
1190 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._nbuf as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1200:19
     |
1200 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._lb as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1210:19
     |
1210 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._blksize as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1220:19
     |
1220 |         unsafe { &(*(::std::ptr::null::<__sFILE>()))._offset as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1877:19
     |
1877 |         unsafe { &(*(::std::ptr::null::<__va_list_tag>())).gp_offset as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1887:19
     |
1887 |         unsafe { &(*(::std::ptr::null::<__va_list_tag>())).fp_offset as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1897:19
     |
1897 |         unsafe { &(*(::std::ptr::null::<__va_list_tag>())).overflow_arg_area as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: dereferencing a null pointer
    --> /Volumes/projects/futz/wxWidgets-rs/target/debug/build/wxWidgets-rs-203d5b329102047f/out/bindings.rs:1907:19
     |
1907 |         unsafe { &(*(::std::ptr::null::<__va_list_tag>())).reg_save_area as *const _ as usize },
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed

warning: 63 warnings emitted

    Finished test [unoptimized + debuginfo] target(s) in 2.35s
     Running unittests (target/debug/deps/wxWidgets_rs-4a3457c2fe935080)

running 16 tests
test bindgen_test_layout___mbstate_t ... ok
test bindgen_test_layout___darwin_pthread_handler_rec ... ok
test bindgen_test_layout___sFILE ... ok
test bindgen_test_layout___sbuf ... ok
test bindgen_test_layout__opaque_pthread_cond_t ... ok
test bindgen_test_layout__opaque_pthread_attr_t ... ok
test bindgen_test_layout___va_list_tag ... ok
test bindgen_test_layout__opaque_pthread_condattr_t ... ok
test bindgen_test_layout__opaque_pthread_mutex_t ... ok
test bindgen_test_layout__opaque_pthread_mutexattr_t ... ok
test bindgen_test_layout__opaque_pthread_once_t ... ok
test bindgen_test_layout__opaque_pthread_rwlock_t ... ok
test bindgen_test_layout__opaque_pthread_rwlockattr_t ... ok
test bindgen_test_layout__opaque_pthread_t ... ok
    block 1: crc = 0x25f07035, combined CRC = 0x25f07035, size = 1180
test bindgen_test_layout_bz_stream ... ok
        bucket sorting ...
        depth      1 has   1172 unresolved strings
        depth      2 has   1039 unresolved strings
        depth      4 has    686 unresolved strings
        depth      8 has    347 unresolved strings
        depth     16 has    110 unresolved strings
        depth     32 has     44 unresolved strings
        depth     64 has      0 unresolved strings
        reconstructing block ...
      1180 in block, 878 after MTF & 1-2 coding, 57+2 syms in use
      initial group 4, [0 .. 1], has 284 syms (32.3%)
      initial group 3, [2 .. 4], has 186 syms (21.2%)
      initial group 2, [5 .. 15], has 207 syms (23.6%)
      initial group 1, [16 .. 58], has 201 syms (22.9%)
      pass 1: size is 1050, grp uses are 3 4 2 9
      pass 2: size is 495, grp uses are 2 4 1 11
      pass 3: size is 494, grp uses are 2 4 0 12
      pass 4: size is 493, grp uses are 2 4 0 12
      bytes: mapping 19, selectors 6, code lengths 56, codes 493
    final combined CRC = 0x25f07035

    [1: huff+mtf rt+rld {0x25f07035, 0x25f07035}]
    combined CRCs: stored = 0x25f07035, computed = 0x25f07035test tests::round_trip_compression_decompression ... ok

test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests wxWidgets-rs

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Expected Results

I would expect output to match the output shown on the doc page.

There are 2 "errors" to me:

  1. The first warning about the panic message not being a string literal - possibly this is a version conflict on my end?
  2. The many null dereference warnings, which I understand to be expected behavior with cargo test, but is not mentioned in the tutorial, and is alarming to see as a first-time user.
@LoganDark
Copy link

LoganDark commented Oct 25, 2021

Oh hey, someone else trying to make bindings to wxWidgets - ...

Don't even try, bindgen does not support C++. C++ is so cursed that not even different C++ versions can interact with each other, and bindgen cannot even begin to understand classes

@rustonaut
Copy link

rustonaut commented Nov 5, 2021

Through bindgen could add #![allow(deref_nullptr)] to the alignment tests it generates (which are also not sound, but might be the (currently) best way to do given tests as far as I can tell.)

@lu-zero
Copy link
Contributor

lu-zero commented Feb 7, 2022

The autogenerated tests should avoid doing that.

@rustonaut
Copy link

By now the auto generated tests might be able to use addr_of to get field pointers without de-referencing, preferable in combination with NonNull::dangling() instead of null pointers.

@khklau
Copy link

khklau commented Mar 22, 2022

I've run into the same warnings with my Apache2 and APR bindings. It's a relief to hear that the null pointer de-referencing is only in the auto-generated tests.

But yes having this in the explained in FAQ or the tutorial documentation would be nice until a proper solution using addr_of is available.

@kulp kulp linked a pull request May 17, 2022 that will close this issue
@kulp
Copy link
Member

kulp commented May 17, 2022

The null deference warnings are resolved in #2203.

I am pretty sure the message about the string literal is not from bindgen.

Let me know if you think differently.

@kulp kulp closed this as completed May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants