Skip to content

Problem with sizeof accessing a class member inside a struct #11408

@behdad

Description

@behdad
Bugzilla Link 11036
Version unspecified
OS Linux
CC @berolinux,@efriedma-quic

Extended Description

With the following code:

class C {
        int i;

        void f (void) {
                typedef int a[sizeof (i)];
                typedef struct {
                        int a[sizeof (i)];
                } s;
        }
};

I get the following error from clang:

a.cc:7:18: error: invalid use of nonstatic data member 'i'
                        int a[sizeof (i)];
                                      ^
1 error generated.

Ie. clang doesn't like sizeof(i) in a struct, but it's ok in a non-struct. Looks like a bug to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"enhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions