Skip to content

Adding _Nonnull attribute causes template deduction to fail #134356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ilya-biryukov opened this issue Apr 4, 2025 · 1 comment · Fixed by #134361
Closed

Adding _Nonnull attribute causes template deduction to fail #134356

ilya-biryukov opened this issue Apr 4, 2025 · 1 comment · Fixed by #134361
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@ilya-biryukov
Copy link
Contributor

https://gcc.godbolt.org/z/MW94Ezd11

template <class T> struct Base {};
template <class T> struct Derived : Base<T> {};

template <class T> void foo(Base<T> *_Nonnull);

template <class T> void bar(Base<T> *);


void test() {
    Derived<int> d;
    foo(&d); // fails.
    bar(&d); // okay.
}
@ilya-biryukov ilya-biryukov added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Apr 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2025

@llvm/issue-subscribers-clang-frontend

Author: Ilya Biryukov (ilya-biryukov)

https://gcc.godbolt.org/z/MW94Ezd11
template &lt;class T&gt; struct Base {};
template &lt;class T&gt; struct Derived : Base&lt;T&gt; {};

template &lt;class T&gt; void foo(Base&lt;T&gt; *_Nonnull);

template &lt;class T&gt; void bar(Base&lt;T&gt; *);


void test() {
    Derived&lt;int&gt; d;
    foo(&amp;d); // fails.
    bar(&amp;d); // okay.
}

@ilya-biryukov ilya-biryukov self-assigned this Apr 4, 2025
ilya-biryukov added a commit to ilya-biryukov/llvm-project that referenced this issue Apr 4, 2025
…se conversions

Fix llvm#134356.

We accidentally skipped checking derived-to-base conversions because
deduction did not strip sugar in the relevant code. This caused deduction
failures when a parameter type had an attribute.
ilya-biryukov added a commit that referenced this issue Apr 4, 2025
…se conversions (#134361)

Fix #134356.

We accidentally skipped checking derived-to-base conversions because
deduction did not strip sugar in the relevant code. This caused
deduction failures when a parameter type had an attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
2 participants