[LLVMbugs] [Bug 16407] New: Assignment from "void *" without cast treated as error within extern "C" block

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 21 11:23:30 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16407

            Bug ID: 16407
           Summary: Assignment from "void *" without cast treated as error
                    within extern "C" block
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gibbs at FreeBSD.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

[gibbs at aslan ~]$ cat foo.cpp

#ifdef __cplusplus
extern "C" {
#endif

struct foo {
    int a;
};

static inline void
initialize_foo(void *data)
{
    struct foo *foo = data;

    foo->a = 1;
}

#ifdef __cplusplus
}
#endif

int
main(int argc, const char *argv[])
{
    struct foo my_foo;

    initialize_foo(&my_foo);

    return (0);
}
[gibbs at aslan ~]$ clang++ -v
FreeBSD clang version 3.3 (trunk 178860) 20130405
Target: x86_64-unknown-freebsd10.0
Thread model: posix
[gibbs at aslan ~]$ clang++ foo.cpp
foo.cpp:13:14: error: cannot initialize a variable of type 'struct foo *' with
      an lvalue of type 'void *'
        struct foo *foo = data;
                    ^     ~~~~
1 error generated.

The work around for this is trivial, but in our environment would mean forking
a third party C header file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130621/ffbda2f3/attachment.html>


More information about the llvm-bugs mailing list