{"action":"opened","issue":{"url":"https://api.github.com/repos/servo/rust-bindgen/issues/639","repository_url":"https://api.github.com/repos/servo/rust-bindgen","labels_url":"https://api.github.com/repos/servo/rust-bindgen/issues/639/labels{/name}","comments_url":"https://api.github.com/repos/servo/rust-bindgen/issues/639/comments","events_url":"https://api.github.com/repos/servo/rust-bindgen/issues/639/events","html_url":"https://github.com/servo/rust-bindgen/issues/639","id":222216546,"number":639,"title":"Struct typedef in class fails with wrong struct size","user":{"login":"drewkett","id":2132248,"avatar_url":"https://avatars1.githubusercontent.com/u/2132248?v=3","gravatar_id":"","url":"https://api.github.com/users/drewkett","html_url":"https://github.com/drewkett","followers_url":"https://api.github.com/users/drewkett/followers","following_url":"https://api.github.com/users/drewkett/following{/other_user}","gists_url":"https://api.github.com/users/drewkett/gists{/gist_id}","starred_url":"https://api.github.com/users/drewkett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewkett/subscriptions","organizations_url":"https://api.github.com/users/drewkett/orgs","repos_url":"https://api.github.com/users/drewkett/repos","events_url":"https://api.github.com/users/drewkett/events{/privacy}","received_events_url":"https://api.github.com/users/drewkett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-17T20:04:26Z","updated_at":"2017-04-17T20:04:26Z","closed_at":null,"body":"### Input C/C++ Header\r\n\r\n```C++\r\nclass Foo {\r\n    public:\r\n    typedef struct {\r\n        int abc;\r\n    } Bar;\r\n\r\n    Bar bar;\r\n};\r\n```\r\n\r\n### Bindgen Invokation\r\n\r\n```\r\n$ bindgen input.h -- -x c++\r\n```\r\n\r\n### Actual Results\r\n\r\n```\r\nERROR:bindgen::codegen::struct_layout: Calculated wrong layout for Foo, too more 4 bytes\r\n```\r\n\r\n```rust\r\n/* automatically generated by rust-bindgen */\r\n\r\n#[repr(C)]\r\n#[derive(Debug, Copy)]\r\npub struct Foo {\r\n    pub __bindgen_anon_1: Foo_Bar,\r\n    pub bar: Foo_Bar,\r\n}\r\n#[repr(C)]\r\n#[derive(Debug, Copy)]\r\npub struct Foo_Bar {\r\n    pub abc: ::std::os::raw::c_int,\r\n}\r\n#[test]\r\nfn bindgen_test_layout_Foo_Bar() {\r\n    assert_eq!(::std::mem::size_of::<Foo_Bar>() , 4usize , concat ! (\r\n               \"Size of: \" , stringify ! ( Foo_Bar ) ));\r\n    assert_eq! (::std::mem::align_of::<Foo_Bar>() , 4usize , concat ! (\r\n                \"Alignment of \" , stringify ! ( Foo_Bar ) ));\r\n    assert_eq! (unsafe {\r\n                & ( * ( 0 as * const Foo_Bar ) ) . abc as * const _ as usize }\r\n                , 0usize , concat ! (\r\n                \"Alignment of field: \" , stringify ! ( Foo_Bar ) , \"::\" ,\r\n                stringify ! ( abc ) ));\r\n}\r\nimpl Clone for Foo_Bar {\r\n    fn clone(&self) -> Self { *self }\r\n}\r\n#[test]\r\nfn bindgen_test_layout_Foo() {\r\n    assert_eq!(::std::mem::size_of::<Foo>() , 4usize , concat ! (\r\n               \"Size of: \" , stringify ! ( Foo ) ));\r\n    assert_eq! (::std::mem::align_of::<Foo>() , 4usize , concat ! (\r\n                \"Alignment of \" , stringify ! ( Foo ) ));\r\n    assert_eq! (unsafe {\r\n                & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } ,\r\n                0usize , concat ! (\r\n                \"Alignment of field: \" , stringify ! ( Foo ) , \"::\" ,\r\n                stringify ! ( bar ) ));\r\n}\r\nimpl Clone for Foo {\r\n    fn clone(&self) -> Self { *self }\r\n}\r\n\r\n```\r\n\r\n### Expected Results\r\n\r\nThe struct typedef shouldn't be a member of the Foo struct. "}}
{"actor":{"display_login":"drewkett"}}