{"action":"created","issue":{"url":"https://api.github.com/repos/rpav/c2ffi/issues/19","labels_url":"https://api.github.com/repos/rpav/c2ffi/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/rpav/c2ffi/issues/19/comments","events_url":"https://api.github.com/repos/rpav/c2ffi/issues/19/events","html_url":"https://github.com/rpav/c2ffi/issues/19","id":113178829,"number":19,"title":"c2ffi fails with an assert","user":{"login":"attila-lendvai","id":840345,"avatar_url":"https://avatars.githubusercontent.com/u/840345?v=3","gravatar_id":"","url":"https://api.github.com/users/attila-lendvai","html_url":"https://github.com/attila-lendvai","followers_url":"https://api.github.com/users/attila-lendvai/followers","following_url":"https://api.github.com/users/attila-lendvai/following{/other_user}","gists_url":"https://api.github.com/users/attila-lendvai/gists{/gist_id}","starred_url":"https://api.github.com/users/attila-lendvai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attila-lendvai/subscriptions","organizations_url":"https://api.github.com/users/attila-lendvai/orgs","repos_url":"https://api.github.com/users/attila-lendvai/repos","events_url":"https://api.github.com/users/attila-lendvai/events{/privacy}","received_events_url":"https://api.github.com/users/attila-lendvai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-24T19:38:25Z","updated_at":"2015-10-24T20:35:26Z","closed_at":null,"body":"i'm on debian stable, happens with both libbluetooth-dev 5.33-1 (testing) and 5.23-2+b1 (stable).\r\n\r\nbluez.h:\r\n```\r\n#include <unistd.h>\r\n#include <fcntl.h>\r\n#include <errno.h>\r\n#include <sys/ioctl.h>\r\n#include <bluetooth/bluetooth.h>\r\n#include <bluetooth/hci.h>\r\n#include <bluetooth/hci_lib.h>\r\n```\r\n\r\ntmp.h:\r\n```\r\n#include \"bluez.h\"\r\n#include \"macros.h\"\r\n```\r\n\r\nfirst phase works as expected:\r\n```\r\nc2ffi bluez.h -M macros.h -A x86_64-pc-linux-gnu\r\n```\r\n\r\nsecond phase dies with assert:\r\n```\r\nc2ffi tmp.h -o delme -A x86_64-pc-linux-gnu\r\n[...]\r\nSkipping invalid Decl:\r\nFunctionDecl 0x3273880 </usr/include/bluetooth/bluetooth.h:336:1, col:28> col:7 invalid bt_malloc 'void *(int)'\r\n`-ParmVarDecl 0x32737c0 <col:17, col:24> col:24 invalid size 'int'\r\nc2ffi: /media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h:131: T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]: Assertion `is<T>() && \"Invalid accessor called\"' failed.\r\nAborted\r\n```\r\n\r\nwhen run in gdb the backtrace is:\r\n```\r\n[...]\r\nSkipping invalid Decl:\r\nFunctionDecl 0x2493880 </usr/include/bluetooth/bluetooth.h:336:1, col:28> col:7 invalid bt_malloc 'void *(int)'\r\n`-ParmVarDecl 0x24937c0 <col:17, col:24> col:24 invalid size 'int'\r\nc2ffi: /media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h:131: T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]: Assertion `is<T>() && \"Invalid accessor called\"' failed.\r\n\r\nProgram received signal SIGABRT, Aborted.\r\n0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n56\t../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) backtrace\r\n#0  0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n#1  0x00007ffff67bc4e8 in __GI_abort () at abort.c:89\r\n#2  0x00007ffff67b4226 in __assert_fail_base (fmt=0x7ffff68eace8 \"%s%s%s:%u: %s%sAssertion `%s' failed.\\n%n\", assertion=assertion@entry=0x1393768 \"is<T>() && \\\"Invalid accessor called\\\"\", \r\n    file=file@entry=0x139378d \"/media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h\", line=line@entry=131, \r\n    function=function@entry=0x13937c8 \"T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]\")\r\n    at assert.c:92\r\n#3  0x00007ffff67b42d2 in __GI___assert_fail (assertion=0x1393768 \"is<T>() && \\\"Invalid accessor called\\\"\", file=0x139378d \"/media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h\", line=131, \r\n    function=0x13937c8 \"T llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>::get() const [PT1 = const clang::ValueDecl *, PT2 = const clang::Expr *, T = const clang::Expr *]\") at assert.c:101\r\n#4  0x0000000000410752 in get<clang::Expr const*> (this=<optimized out>) at /media/store/work/llvm-3.6/include/llvm/ADT/PointerUnion.h:131\r\n#5  c2ffi::C2FFIASTConsumer::make_decl (this=<optimized out>, d=<optimized out>, is_toplevel=<optimized out>) at AST.cpp:224\r\n#6  0x000000000040fc10 in c2ffi::C2FFIASTConsumer::HandleDecl (this=0x22b76d0, d=0x269de50, ns=<optimized out>) at AST.cpp:101\r\n#7  0x00000000004121fd in c2ffi::C2FFIASTConsumer::HandleTopLevelDecl (this=0x22b76d0, d=...) at AST.cpp:145\r\n#8  0x000000000078d2ac in clang::ParseAST(clang::Sema&, bool, bool) ()\r\n#9  0x000000000078d062 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, clang::TranslationUnitKind, clang::CodeCompleteConsumer*, bool) ()\r\n#10 0x00000000004084ea in main (argc=<optimized out>, argv=<optimized out>) at c2ffi.cpp:94\r\n```\r\n\r\nif i run c2ffi only on macros.h (i.e. not on tmp.h) then it fails with a different assert:\r\n```\r\n[...]\r\nmacros.h:9703:45: error: expected expression\r\nconst long __c2ffi___need_NULL = __need_NULL;\r\n                                            ^\r\nc2ffi: /media/store/work/llvm/tools/clang/lib/Sema/Sema.cpp:249: clang::Sema::~Sema(): Assertion `DelayedTypos.empty() && \"Uncorrected typos!\"' failed.\r\n\r\nProgram received signal SIGABRT, Aborted.\r\n0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n56\t../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) backtrace\r\n#0  0x00007ffff67bb107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n#1  0x00007ffff67bc4e8 in __GI_abort () at abort.c:89\r\n#2  0x00007ffff67b4226 in __assert_fail_base (fmt=0x7ffff68eace8 \"%s%s%s:%u: %s%sAssertion `%s' failed.\\n%n\", assertion=assertion@entry=0x14ea360 \"DelayedTypos.empty() && \\\"Uncorrected typos!\\\"\", \r\n    file=file@entry=0x14ea328 \"/media/store/work/llvm/tools/clang/lib/Sema/Sema.cpp\", line=line@entry=249, function=function@entry=0x14ee2d0 <clang::Sema::~Sema()::__PRETTY_FUNCTION__> \"clang::Sema::~Sema()\")\r\n    at assert.c:92\r\n#3  0x00007ffff67b42d2 in __GI___assert_fail (assertion=0x14ea360 \"DelayedTypos.empty() && \\\"Uncorrected typos!\\\"\", file=0x14ea328 \"/media/store/work/llvm/tools/clang/lib/Sema/Sema.cpp\", line=249, \r\n    function=0x14ee2d0 <clang::Sema::~Sema()::__PRETTY_FUNCTION__> \"clang::Sema::~Sema()\") at assert.c:101\r\n#4  0x000000000084bd9b in clang::Sema::~Sema() ()\r\n#5  0x000000000043829c in std::default_delete<clang::Sema>::operator()(clang::Sema*) const ()\r\n#6  0x0000000000432c27 in std::unique_ptr<clang::Sema, std::default_delete<clang::Sema> >::~unique_ptr() ()\r\n#7  0x000000000078d07a in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, clang::TranslationUnitKind, clang::CodeCompleteConsumer*, bool) ()\r\n#8  0x00000000004084ea in main (argc=<optimized out>, argv=<optimized out>) at c2ffi.cpp:94\r\n(gdb) \r\n```\r\n\r\nc2ffi seems to be statically linked to llvm:\r\n```\r\n$ ldd /home/alendvai/workspace/c2ffi/src/c2ffi\r\n\tlinux-vdso.so.1 (0x00007ffc49fb3000)\r\n\tlibdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb9350a2000)\r\n\tlibncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007fb934e7d000)\r\n\tlibtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fb934c53000)\r\n\tlibz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb934a38000)\r\n\tlibstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb93472d000)\r\n\tlibm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb93442c000)\r\n\tlibgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb934216000)\r\n\tlibpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb933ff9000)\r\n\tlibc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb933c50000)\r\n\t/lib64/ld-linux-x86-64.so.2 (0x00007fb9352a6000)\r\n```\r\n\r\nthis is how i compiled c2ffi:\r\n```\r\nPATH=/media/store/work/llvm-3.6/bin/:$PATH; LDFLAGS=/media/store/work/llvm-3.6/lib/; ./configure --enable-debug\r\nPATH=/media/store/work/llvm-3.6/bin/:$PATH make -j2\r\n```\r\n\r\nllvm version:\r\n```\r\n$ svn info\r\nPath: .\r\nWorking Copy Root Path: /media/store/work/llvm\r\nURL: http://llvm.org/svn/llvm-project/llvm/branches/release_36\r\nRelative URL: ^/llvm/branches/release_36\r\nRepository Root: http://llvm.org/svn/llvm-project\r\nRepository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8\r\nRevision: 251109\r\nNode Kind: directory\r\nSchedule: normal\r\nLast Changed Author: hans\r\nLast Changed Rev: 240577\r\nLast Changed Date: 2015-06-24 21:50:28 +0200 (Wed, 24 Jun 2015)\r\n```"},"comment":{"url":"https://api.github.com/repos/rpav/c2ffi/issues/comments/150848188","html_url":"https://github.com/rpav/c2ffi/issues/19#issuecomment-150848188","issue_url":"https://api.github.com/repos/rpav/c2ffi/issues/19","id":150848188,"user":{"login":"attila-lendvai","id":840345,"avatar_url":"https://avatars.githubusercontent.com/u/840345?v=3","gravatar_id":"","url":"https://api.github.com/users/attila-lendvai","html_url":"https://github.com/attila-lendvai","followers_url":"https://api.github.com/users/attila-lendvai/followers","following_url":"https://api.github.com/users/attila-lendvai/following{/other_user}","gists_url":"https://api.github.com/users/attila-lendvai/gists{/gist_id}","starred_url":"https://api.github.com/users/attila-lendvai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attila-lendvai/subscriptions","organizations_url":"https://api.github.com/users/attila-lendvai/orgs","repos_url":"https://api.github.com/users/attila-lendvai/repos","events_url":"https://api.github.com/users/attila-lendvai/events{/privacy}","received_events_url":"https://api.github.com/users/attila-lendvai/received_events","type":"User","site_admin":false},"created_at":"2015-10-24T20:35:26Z","updated_at":"2015-10-24T20:35:26Z","body":"if i unpull the commit https://github.com/rpav/c2ffi/commit/4c9cca1a690abfcb2e73145ab88766ea2698a3ad then it runs without an assert."}}