Skip to content

Array pointer treated as array with 0 elements #683

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
polyfloyd opened this issue May 2, 2017 · 2 comments
Closed

Array pointer treated as array with 0 elements #683

polyfloyd opened this issue May 2, 2017 · 2 comments

Comments

@polyfloyd
Copy link

When updating to the latest version of Bindgen I ran into the following line from libflac being treated differently:
https://github.com/oneman/libflac/blob/eb9f5de298314e84f810648def81509a69d628a3/include/FLAC/stream_decoder.h#L288
This line denotes an array of strings which length is defined in the C source:
https://github.com/oneman/libflac/blob/eb9f5de298314e84f810648def81509a69d628a3/src/libFLAC/stream_decoder.c#L227

Input C/C++ Header

extern const char * const array_1[];
extern const char * const *array_2;

Bindgen Invokation

$ bindgen input.h

Actual Results

extern "C" {
    #[link_name = "array_1"]
    pub static mut array_1: [*const ::std::os::raw::c_char; 0usize];
}
extern "C" {
    #[link_name = "array_2"]
    pub static mut array_2: *const *const ::std::os::raw::c_char;
}

Expected Results

extern "C" {
    #[link_name = "array_1"]
    pub static mut array_1: *const *const ::std::os::raw::c_char;
}
extern "C" {
    #[link_name = "array_2"]
    pub static mut array_2: *const *const ::std::os::raw::c_char;
}

It seems that the newer version of bindgen treats the [] syntax as zero sized arrays, while they are meant to be pointers.
As far as I could tell, the new behavior has been introduced in 0.21.

RUST_LOG=bindgen Output

``` INFO:bindgen: Clang Version: clang version 3.9.1-8 (tags/RELEASE_391/rc2) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [] }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: None, loc: None DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(1) ty = Type(const char *const [], kind: IncompleteArray, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), location = Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const [], kind: IncompleteArray, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const [], kind: IncompleteArray, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(1), ty: Type(const char *const [], kind: IncompleteArray, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1")) DEBUG:bindgen::ir::ty: currently_parsed_types: [] DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(2) ty = Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), location = Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(2), ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1")) DEBUG:bindgen::ir::ty: currently_parsed_types: [] DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(3) Type(const char, kind: Char_S, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1")), None DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char, kind: Char_S, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("const char"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Int(Char { is_signed: true }), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::ir::item: ItemId(4) already resolved: Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1")) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(4)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))) DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(4)), is_const: true, detect_has_vtable_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Array(ItemId(2), 0), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))) DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: None, kind: Array(ItemId(2), 0), is_const: false, detect_has_vtable_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "array_1", mangled_name: Some("array_1"), ty: ItemId(1), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))), loc: Some(Cursor(array_1 kind: VarDecl, loc: header.h:1:27, usr: Some("c:@array_1"))) DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(6) ty = Type(const char *const *, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), location = Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const *, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const *, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(6), ty: Type(const char *const *, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")) DEBUG:bindgen::ir::ty: currently_parsed_types: [] DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(7) Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")), None DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::item: New unresolved type reference: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: UnresolvedTypeRef(Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")), None), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: InvalidFile, loc: builtin definitions, usr: None)), loc: None DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: InvalidFile, loc: builtin definitions, usr: None) found for type Type { name: None, layout: None, kind: UnresolvedTypeRef(Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")), None), is_const: true, detect_has_vtable_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(7)), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))) DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(7)), is_const: false, detect_has_vtable_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "array_2", mangled_name: Some("array_2"), ty: ItemId(6), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), loc: Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))) DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(9) ty = Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), location = Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(9), ty: Type(const char *const, kind: Pointer, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")) DEBUG:bindgen::ir::ty: currently_parsed_types: [] DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(10) Type(const char, kind: Char_S, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")), None DEBUG:bindgen::ir::item: refs already collected, resolving directly DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(10) ty = Type(const char, kind: Char_S, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), location = Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(const char, kind: Char_S, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(11), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("const char"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Int(Char { is_signed: true }), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(11)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(array_2 kind: VarDecl, loc: header.h:3:28, usr: Some("c:@array_2"))) DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(11)), is_const: true, detect_has_vtable_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: No replacements to process DEBUG:bindgen::codegen: codegen: BindgenOptions { hidden_types: RegexSet { items: [], set: Some(RegexSet([])) }, opaque_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_functions: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_vars: RegexSet { items: [], set: Some(RegexSet([])) }, bitfield_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enums: RegexSet { items: [], set: Some(RegexSet([])) }, builtins: false, links: [], emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, disable_name_namespacing: false, layout_tests: true, derive_debug: true, derive_default: false, unstable_rust: true, use_core: false, ctypes_prefix: None, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], clang_args: ["-isystem", "/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0", "-isystem", "/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0", "-isystem", "/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward", "-isystem", "/usr/local/include", "-isystem", "/usr/lib/llvm-3.8/bin/../lib/clang/3.8.1/include", "-isystem", "/usr/include/x86_64-linux-gnu", "-isystem", "/usr/include", "header.h"], input_header: Some("header.h"), input_unsaved_files: [], dummy_uses: None, parse_callbacks: None, codegen_config: CodegenConfig { functions: true, types: true, vars: true, methods: true, constructors: true, destructors: true }, conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: false, whitelist_recursively: true, objc_extern_crate: false, enable_mangling: true, prepend_enum_name: true } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [ItemId(2), ItemId(1), ItemId(5), ItemId(7), ItemId(6), ItemId(8), ItemId(9)] }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [ItemId(2), ItemId(1), ItemId(5), ItemId(7), ItemId(6), ItemId(8), ItemId(9)] }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(4)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(4)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Array(ItemId(2), 0), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Array(ItemId(2), 0), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "array_1", mangled_name: Some("array_1"), ty: ItemId(1), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(5), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "array_1", mangled_name: Some("array_1"), ty: ItemId(1), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: ResolvedTypeRef(ItemId(9)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: ResolvedTypeRef(ItemId(9)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(7)), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(7)), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "array_2", mangled_name: Some("array_2"), ty: ItemId(6), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(8), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "array_2", mangled_name: Some("array_2"), ty: ItemId(6), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(11)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(9), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 8, align: 8, packed: false }), kind: Pointer(ItemId(11)), is_const: true, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } ```
@emilio
Copy link
Contributor

emilio commented May 2, 2017

It seems that the newer version of bindgen treats the [] syntax as zero sized arrays, while they are meant to be pointers.

This is the only way they can actually work. The previous behavior doesn't get you the pointer you want, this one does.

If you want the pointer, you can do array_1.as_ptr().

@emilio
Copy link
Contributor

emilio commented May 2, 2017

See also #457 and #456.

Based on that, I believe this is not a bug. Feel free to comment if you have reasons to think differently, and I'll happily reopen :).

Thanks a bunch for the report! :)

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