-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue
Description
To be honest, I'm not entirely sure that this is a clang bug (and @zygoloid can put me in my place quickly enough).
Here's an interesting example:
using size_t = decltype(sizeof(0));
template <size_t N>
void f(const int* const (&)[N]);
template <class T>
void g(T const* const*);
int main() {
int* pointers[3];
f(pointers); // clang: error, gcc: ok
g(pointers); // clang, gcc: ok
const int* const (&h)[3] = pointers; // clang, gcc: ok
}All three of these situations seem similar: we're taking an array of pointers to mutable int (no const anywhere) and trying to add const in two layers:
fis trying to deduce a reference to an array of const pointers to constint(gcc is okay with this, clang fails deduction saying it cannot matchconst int *againstint*)gis trying to deduce a pointer to const pointer to constint(which is similar, and both gcc and clang are fine with this)his just directly binding the same reference thatfwould have, except not in a template deduction context (likewise similar, both gcc and clang are fine with this too)
At the very least, it seems like f and h should either both be valid or both be invalid. So I think it's either a clang bug (so I'm in the right spot) or a C++ bug (and I should be writing this issue in a different spot).
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue