Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bogus error when using __reference_converts_from_temporary in default template argument #132044

Copy link
Copy link
Closed
@aaronpuchert

Description

@aaronpuchert
Issue body actions

We ran into this with an std::function (libstdc++ 13) returning an object with protected copy constructor. It boils down to this:

class X {
protected:
    X(const X&);
};

static_assert(!__reference_converts_from_temporary(X, X));

template<typename A, typename B,
         bool Dangle = __reference_converts_from_temporary(A, B)>
static void test();

using Result = decltype(test<X, X>());

produces:

bug.cpp:9:24: error: calling a protected constructor of class 'X'
    9 |          bool Dangle = __reference_converts_from_temporary(A, B)>
      |                        ^

Replacing either A or B by X doesn't make the error go away. Interestingly, if we define test, for example with an empty body, and do a full instantiation, then the error appears if the instantiation is implicit, but not if it's explicit:

template<typename A, typename B,
         bool Dangle = __reference_converts_from_temporary(A, B)>
static void test() {} // <-- Added an empty body.

template void test<X, X>(); // No error.

void f() {
    test<X, X>(); // Error.
}

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.