Skip to content
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

Global multi-level pointers #1151

Closed
shnewto opened this issue Nov 14, 2017 · 3 comments
Closed

Global multi-level pointers #1151

shnewto opened this issue Nov 14, 2017 · 3 comments

Comments

@shnewto
Copy link
Contributor

shnewto commented Nov 14, 2017

Hello,
I've been working toward implementing property based testing with quickcheck, issue #970 and the tests I have so far are generating some code that fails.

Input C/C++ Header

int ***** simple_decl_71; // fail, 5 levels
// int **** simple_decl_71; // succeed, 4 levels
// int ***** simp_decl_71; // succeed, 5 levels with variable name less than 13 characters

It seems like this is only an issue for globals as far as I can tell because the following code succeeds

struct struct_43 {
    int ***** simple_decl_71; // succeed, 5 levels with variable name greater than 12 characters
};

Invocation

I've been using the csmith-fuzzing/predicate.py script to test so the failing invocation would look like this assuming that line is in a header named multi-level.h

$ ./csmith-fuzzing/predicate.py multi-level.h

Actual Results

Running: ['cargo', 'run', '--manifest-path', '/home/username/src/rust-bindgen/Cargo.toml', '--', 'multi-line.h', '-o', '/tmp/bindings-fzw0x4sl.rs', '--with-derive-partialeq', '--with-derive-eq', '--with-derive-partialord', '--with-derive-ord', '--with-derive-hash', '--with-derive-default']
Running: ['rustc', '--crate-type', 'lib', '--test', '-o', '/tmp/layout-tests-65v9sdg9', '/tmp/bindings-fzw0x4sl.rs']
Error: running `rustc` on the emitted bindings failed
+error: expected item after attributes
+ --> /tmp/bindings-fzw0x4sl.rs:4:44
+  |
+4 |  # [ link_name = "\u{1}_Z14simple_decl_71" ]
+  |                                            ^
+
+error: aborting due to previous error
+

Generated code:

extern "C" {
 # [ link_name = "\u{1}_Z14simple_decl_71" ]
    ;
}

Expected Results

Generated code that looks like this:

extern "C" {
 # [ link_name = "\u{1}_Z14simple_decl_71" ]
    pub static mut simple_decl_71: *mut *mut *mut *mut *mut ::std::os::raw::c_int;
}
@fitzgen
Copy link
Member

fitzgen commented Nov 15, 2017

Thanks for filing a bug @Snewt !

I can't reproduce the behavior you're describing however. I wonder if it is possibly due to an older version of rustfmt? Do you experience the same issue with either

  • adding --no-rustfmt-bindings to the args passed to bindgen through predicate.py, or
  • after ensureing that rustfmt is up-to-date?
$ rustup update nightly
$ cargo +nightly install -f rustfmt-nightly

Thanks!

@shnewto
Copy link
Contributor Author

shnewto commented Nov 15, 2017

Ah! @fitzgen the update steps you provided resolved the issue, thanks for walking me through them.

@fitzgen
Copy link
Member

fitzgen commented Nov 15, 2017

Great!

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

No branches or pull requests

2 participants