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

non-type template-parameter of reference type confuses template specialization matching #40328

Open
llvmbot opened this issue Mar 6, 2019 · 4 comments
Labels
bugzilla Issues migrated from bugzilla c++17

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 6, 2019

Bugzilla Link 40983
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

Consider the following MWE:
-- 8< ---------------------
template<typename T, T v>
struct X {
};

template<bool &v>
struct X<bool &, v> {
};
-- 8< ---------------------

As shown in https://www.godbolt.org/z/HqqLWu, the MWE is accepted by GCC when using C++14 (the compilation switches -std=c++14 -pedantic-errors') and when using C++17 (the compilation switches -std=c++17 -pedantic-errors').

Clang also accepts the MWE when using C++14 but not when using C++17.

A thread in the C++ std-discussion has just been started on this matter (see https://groups.google.com/a/isocpp.org/d/msg/std-discussion/etn0e3qhz28/Nmpmz7NwBAAJ), but no one has replied yet. Nevertheless, I think this is a bug considering that Clang accepts the MWE in C++14, and I think, there is no change in C++17 that justifies Clang behavior in rejecting the MWE in C++17.

This bug may also be related to this bug: #38721

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Mar 7, 2019

A thread in the C++ std-discussion has just been started

std-discussions is pretty broken right now; it randomly rejects a significant amount of mail as "spam" :(

The problem is that in C++17 onwards, the type of a non-type template parameter is deduced from the type of the argument. In C++14 and before, deducing the parameters of X from <bool&, v> deduces T=bool& from the first argument and v=v from the second. But in C++17 onwards, we also deduce T=bool from the second argument, which results in that no longer being a valid specialization, because we "don't know" what type T should be.

I'm going to raise this with the C++ committee; I think this is a defect in P0127R2.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented May 10, 2019

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 13, 2019

I'm going to raise this with the C++ committee; I think this is a defect in
P0127R2.

Has this issue been raised with the C++ committee?

Thank you.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 27, 2021

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
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
Projects
None yet
Development

No branches or pull requests

1 participant