Skip to content

clang-format adds unnecessary space before & when :: operator is used #111011

Closed
@mkaz101

Description

@mkaz101

I experienced a strange bug in clang-format in version 19.1.1. I didn't observe it in version 16 (which I previously used in my project).
I have a setting to keep reference (&) signs glued to the type on the left side (ReferenceAlignment: Left). This formatting works for most functions, however if the function is in global scope (prepended with ::) clang-format is adding additional space between the type and &.

Here is the small code snippet that I used for testing.

class test {
  friend std::ostream& ::operator<<(std::ostream & lhs,
                                    const ::test_1::test2 &
                                        rhs);

  friend std::ostream& operator<<(std::ostream& lhs,
                                  const ::test_1::test2& rhs);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions