Skip to content

[clang-format] Inconsistent formatting in case of SpacesInParensOptions.InCStyleCasts = false and Other = true #102874

@dmitry-zakablukov

Description

@dmitry-zakablukov

Consider this source:

void main() {
    int a = ( int ) ( 1 + 2 );
    int b = ( Namespace::Class ) ( 1 + 2 );
    int c = ( Class ) ( 1 + 2 );
}

...and this .clang-format:

BasedOnStyle: LLVM
IndentWidth: 4
Language: Cpp
SpacesInParens: Custom
SpacesInParensOptions:
  InCStyleCasts: false
  Other: true

Running clang-format puts the spaces in C-style cast in case of namespace presense:

void main() {
    int a = (int)( 1 + 2 );
    int b = ( Namespace::Class )( 1 + 2 );
    int c = (Class)( 1 + 2 );
}

Tested with clang-format 18 and 19, on Windows and macOS.

This issue may have the same bug nature as in #64416.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions