Skip to content
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

Type mismatch for pointer to template template function #48423

Closed
pavelkryukov opened this issue Feb 7, 2021 · 8 comments
Closed

Type mismatch for pointer to template template function #48423

pavelkryukov opened this issue Feb 7, 2021 · 8 comments
Labels
bugzilla Issues migrated from bugzilla c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate

Comments

@pavelkryukov
Copy link

Bugzilla Link 49079
Version 11.0
OS All
CC @dwblaikie,@GabrielRavier,@zygoloid

Extended Description

If a function is a template template function (template<template class> void foo(int&)), and a template template parameter has a default value, it does not fit to function pointer type.

Example:

template<typename, typename = int> class A { };

template<template class> void foo(int&);
void bar(void(*)(int&));

int main()
{
bar(foo);
}
Output:

:8:5: error: no matching function for call to 'bar' bar(foo); ^~~ :4:6: note: candidate function not viable: no overload of 'foo' matching 'void (*)(int &)' for 1st argument void bar(void(*)(int&));

Godbolt: https://godbolt.org/z/enhYs8

With GCC and MSVC, example compiles fine.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Feb 8, 2021

Clang implements the language change that makes this code valid, but doesn't enable it by default. As a workaround, you can use -frelaxed-template-template-args to accept this code.

@pavelkryukov
Copy link
Author

I see... Thank you!

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Feb 17, 2021

*** Bug llvm/llvm-bugzilla-archive#49224 has been marked as a duplicate of this bug. ***

@GabrielRavier
Copy link
Contributor

Is there any particular reason why Clang doesn't enable this by default ?

@pavelkryukov
Copy link
Author

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#49224

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Jul 4, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 4, 2022

@llvm/issue-subscribers-clang-frontend

@mizvekov
Copy link
Contributor

Duplicate of #42224

@mizvekov mizvekov marked this as a duplicate of #42224 Apr 27, 2024
@mizvekov mizvekov closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2024
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

5 participants