[LLVMbugs] [Bug 21350] New: sizeof on member of a nested class does not compile with error invalid use of non-static data member

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 22 20:07:34 PDT 2014


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

            Bug ID: 21350
           Summary: sizeof on member of a nested class does not compile
                    with error invalid use of non-static data member
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at gyoo.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In c++98 sizeof on a non-static struct member was not legal without an
instance. c++11 allow it.
It's working fine with struct but not with nested struct.

Here an example to trigger the problem:

#include <iostream>

struct Foo 
{
    int m_member;

    struct Nested 
    {
        int m_nestedMember;
    };

    Foo()
    {
        std::cout << sizeof(Foo::m_member);          // Ok
        std::cout << sizeof(Nested::m_nestedMember); // Bug in clang in c++11
mode: error: invalid use of non-static data member 'm_nestedMember'
    }
};

int main()
{
    Foo foo;

    return 0;
}

-- 
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/20141023/fd1776bd/attachment.html>


More information about the llvm-bugs mailing list