Skip to content

Clang-format 18: Inconsistent ampersand and pointer star spacing with function parameters with nested/interface scope #100729

@vesterij

Description

@vesterij

clang-format version 18.1.8 and default config

Formatting following code will replicate the issue.

#pragma once

namespace Helper {

    // Correct: CMyClass& myclass
    HRESULT GetSomething(CMyClass& myclass);

    interface MyInterface {
	 // Wrong: CMyClass & myclass
        HRESULT GetSomethingElse(CMyClass& myclass);
    }
}

Clang-format with default config will change formatting a lot but the probem is that when references or pointers to function parameters are first parameters there is an extra space.

You get:
CMyClass & myclass
Instead of:
CMyClass& myclass

But this is only if there is a nested scope (like with MSVC interface) and object is first paramater.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorclang-format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions