Skip to content

[clang-format] bit-field that has its size specified using a variable with :: can be misformatted #153448

@joelhock

Description

@joelhock

clang-format version 20.1.0 (https://github.com/llvm/llvm-project.git 24a30da) correctly formatted this code:

struct struct_with_constexpr {
  static constexpr unsigned int i_am_a_constexpr_lengthhhhh = 2;
};

struct foo {
  uint8_t i_am_a_bit_field_this_long
      : struct_with_constexpr::i_am_a_constexpr_lengthhhhh;
};

whereas clang-format version 21.1.0-rc3 (https://github.com/llvm/llvm-project.git 6096d35) misformats it, breaking on the ::

struct struct_with_constexpr {
  static constexpr unsigned int i_am_a_constexpr_lengthhhhh = 2;
};

struct foo {
  uint8_t i_am_a_bit_field_this_long : struct_with_constexpr::
      i_am_a_constexpr_lengthhhhh;
};

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions