Skip to content

clang-format: Incorrectly formats multiplication as if it was pointer dereference #110879

@griffin2000

Description

@griffin2000

In the attached example (test.cpp.txt, renamed to .txt so it can be attached) using the attached .clang-format settings (clang-format.txt, also renamed to .txt and . prefix removed), the second line of the struct is formatted by clang-format (v 14.0.0) as if it was a pointer de-reference, and the space following the * is removed.

So this...


constexpr Thingy kConfig = {
    {
        (uint16_t)(kScale * kThing.width_pixels),
        (uint16_t)(kScale * kThing.height_pixels),
    },
};

Becomes:

constexpr Thingy kConfig = {
    {
        (uint16_t)(kScale * kThing.width_pixels),
        (uint16_t)(kScale *kThing.height_pixels),
    },
};

The expected behaviour is the space should be maintained, or added if it it is removed (if either the space before or after the * is removed on the previous line, it will be added back by clang-format)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions