Skip to content

clang++-19: rejects-valid #92188

@egorpugin

Description

@egorpugin

https://godbolt.org/z/E5xqebhfK

struct A {
    template <auto N>
    void operator+=(this auto &&obj, const char (&c)[N]) {
    }
    void operator+=(this auto &&obj, auto &&c) {
    }
};

int main() {
    A a;
    a += "123";
}
<source>:11:7: error: use of overloaded operator '+=' is ambiguous (with operand types 'A' and 'const char[4]')
   11 |     a += "123";
      |     ~ ^  ~~~~~
<source>:3:10: note: candidate function [with N = 4UL, obj:auto = A &]
    3 |     void operator+=(this auto &&obj, const char (&c)[N]) {
      |          ^
<source>:5:10: note: candidate function [with obj:auto = A &, c:auto = const char (&)[4]]
    5 |     void operator+=(this auto &&obj, auto &&c) {
      |          ^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"rejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions