https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108169

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, take:
```
struct W {
    constexpr W(int i) : i(i) {}
    int i;
};

template <auto V>
struct S {
    static constexpr decltype(V) &t = V;
};
int main() {
    const W *t = &S<W(2)>::t;
}
```
Clang produces:
```
<source>:7:35: error: binding reference of type 'decltype(W{2})' (aka 'W') to
value of type 'const W' drops 'const' qualifier
    static constexpr decltype(V) &t = V;
                                  ^   ~
<source>:10:28: note: in instantiation of static data member 'S<W{2}>::t'
requested here
    const W *t = &S<W(2)>::t;
                           ^
```
So clang thinks V is const too in some cases ....

Even MSVC produces:
```
<source>(7): error C2440: 'initializing': cannot convert from 'const W' to 'W
&'
<source>(7): note: Conversion loses qualifiers
<source>(10): note: see reference to class template instantiation 'S<W{int:2}>'
being compiled
```
Notice the `const W` there.

Note for scalar types (though float is broken for clang because it is not
implemented yet), it is always non-const ...

Reply via email to