Skip to content

[clang-format] Misformatted braces when base class contains square brackets #53293

@mkurdej

Description

@mkurdej

Commit 5c2e7c9 introduced a regression (w.r.t. v13). @mydeveloperday

Style: LLVM

Input/expected:

template <typename = void> struct S {};
template <> struct S : Template<int (*)[]> {};

Output:

template <typename = void> struct S {};
template <> struct S : Template<int (*)[]>{};

The first line is for comparison only.
Mind the missing space before {} on the second line.

This code is just a minimal repro of https://github.com/tcbrindle/span/blob/master/include/tcb/span.hpp#L274 (a bit differently formatted):

template <typename, typename, typename = void>
struct is_container_element_type_compatible : std::false_type {};

template <typename T, typename E>
struct is_container_element_type_compatible<
    T, E,
    typename std::enable_if<
        !std::is_same<typename std::remove_cv<decltype(detail::data(
                          std::declval<T>()))>::type,
                      void>::value &&
        std::is_convertible<
            remove_pointer_t<decltype(detail::data(std::declval<T>()))> (*)[],
            E (*)[]>::value>::type> : std::true_type {};

Using config BreakBeforeBraces: Allman makes the issues be even more visible (but is not related AFAICT).

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorclang-formatregression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions