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

            Bug ID: 19266
           Summary: C++11-style sizeof does not compile in certain cases.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Consider this artificial code:

    struct foo
    {
        int bar;
    };

    template <typename T>
    struct A { };

    template <typename T>
    struct B : public A<T>
    {
        void baz()
        {
            enum { count = sizeof(foo::bar) };
        }
    };

    int main(int, char *[])
    {
        B<int>().baz();
        return 0;
    }

clang++ -std=c++11 bug.cpp produces following output:

    bug.cpp:14:36: fatal error: 'foo::bar' is not a member of class 'B<int>'
            enum { count = sizeof(foo::bar) };
                                  ~~~~~^
    bug.cpp:20:14: note: in instantiation of member function 'B<int>::baz'
requested here
        B<int>().baz();

I see this error with both clang 3.4 on Linux and 3.5.r203967 snapshot on
Windows, so I
suppose that it fails in trunk too (can't test it unfortunately). Compilation
does not
fail if:
    - B::baz is turned into static function;
    - enum is moved to struct B's scope;
    - I use sizeof(static_cast<foo*>(0)->bar) instead of sizeof(foo::bar);
    - A and/or B are not template types.

GCC 4.8 compiles this code without errors.

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