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

           Summary: Namespace and extern "C" gives problems with forward
                    struct declarations
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


Clang has a problem compiling the gstreamer backend for KDE's phonon
library.  I encountered this issue with trunk r125004.  The reduced C++
code goes like this:

namespace Gstreamer {
  extern "C" {
    typedef struct _ArtsSink ArtsSink;
    struct _ArtsSink {
      int sink;
    };
  }
  int arts_sink_get_type()
  {
    return sizeof(ArtsSink);
  }
}

Compiling this with clang++ gives:

fwddecl.cpp:10:12: error: invalid application of 'sizeof' to an incomplete type
'ArtsSink' (aka 'Gstreamer::_ArtsSink')
    return sizeof(ArtsSink);
           ^     ~~~~~~~~~~
fwddecl.cpp:3:20: note: forward declaration of 'Gstreamer::_ArtsSink'
    typedef struct _ArtsSink ArtsSink;
                   ^
1 error generated.

Granted, it is a bit weird how the KDE guys forward declare the
_ArtsSink struct, but as far as I can see, it should still compile.

I tried this fragment with g++ 4.2.1 (FreeBSD base system compiler), g++
4.5.3, and Coumeau 4.3.10.1, and they all accept it without any
complaint.

Note: the error goes away when you eliminate either the namespace or the
'extern "C"' block.  Both are required to produce the error.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to