[LLVMbugs] [Bug 11299] New: clang rejects nested struct-member-access-typeof

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 2 14:10:47 PDT 2011


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

             Bug #: 11299
           Summary: clang rejects nested struct-member-access-typeof
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


(This is a copy-paste of a message from Jan Engelhardt to cfe-dev.)

== Compiler info (clang -v) ==

[openSUSE 12.1 RC]
SUSE Linux clang version 3.0 (trunk 140782) (based on LLVM 3.0)
Target: x86_64-unknown-linux-gnu
Thread model: posix

== Source ==

int main(void)
{
       void *p = 0;
       typeof((struct { typeof((struct { void *m; }){p}.m) n; }){0}.n) q = 0;
       return 0;
}

== Description ==

I was giving clang a spin on libHX [http://libhx.sf.net/] when it errored out
on libHX's "type-checking casts" macros. The above source snippet is the
distilled minimal test case.

../../src/format.c:34:29: error: initializer element is not a compile-time
     constant
       return const_cast1(void *, static_cast(const void *, t));
              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...]



== Observed output ==

$ clang test.c
t.c:4:47: error: initializer element is not a compile-time constant
       typeof((struct { typeof((struct { void *m; }){p}.m) n; }){0}.n) q = 0;
                                                    ^~~
t.c:4:63: error: member reference base type 'void' is not a structure or union
       typeof((struct { typeof((struct { void *m; }){p}.m) n; }){0}.n) q = 0;
                                                                ~~~ ^
2 errors generated.


== Expected output ==

That no errors be output. GCC 4.5/4.6/4.x compiles the very same file
fine, because it sees that we are really only doing type inspection.

-- 
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.



More information about the llvm-bugs mailing list