Skip to content

[clang] clang fails to recognize a reference binding from prvalue with const qualification to rvalue ref during overloading resolution is ill-formed. #132600

@changkhothuychung

Description

@changkhothuychung

Given this program

struct Alloc{}; 

struct MyString
{
    MyString();
    MyString(MyString&&, const Alloc&); 
    MyString(MyString&&); 
    MyString(const MyString&, const Alloc&); 
    MyString(const MyString&); 
};

struct A
{
    operator const MyString() const; 
};

int main() {
    MyString s(A{}, Alloc{}); 
    return 0;
}

Clang reports error no viable conversion from 'A' to 'MyString', but gcc doesn't complain about it. The issue goes away when I change operator const to operator. Is this a bug in clang? If yes, I would like to work on this issue.

link to compiler explorer: https://godbolt.org/z/E7oP6hcP6

Metadata

Metadata

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions