Skip to content

Implicit conversion from long rvalue reference to int rvalue reference via a conversion operator fails #180577

@Fedr

Description

@Fedr

This program

long nil = 0;

struct S {
    operator long &&() const { 
        return static_cast<long&&>(nil);
    }
};

int main() { 
    int &&a((S()));
    return a;
}

is accepted by GCC, EDG and MSVC. But not in Clang:

error: no viable conversion from 'S' to 'int'

Online demo: https://gcc.godbolt.org/z/M7W3oYsGz

This is a slightly modified example from https://stackoverflow.com/q/79885636/7325599

Metadata

Metadata

Assignees

No one assigned

    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