Skip to content

[Clang] constant evaluator thinks that elements of an unnamed struct is not initialized #154567

@philnik777

Description

@philnik777
struct T {
  int i;
};

struct S {
  struct {
    T val;
  };

  constexpr S() : val() {}
  constexpr ~S() {}

  constexpr T get() { return val; }
};

constexpr bool func() {
  S s;
  return s.get().i == 0;
}

static_assert(func());

Here Clang says that val isn't initialized, even though it pretty clearly is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions