[Bug c++/107222] New: const qualifier appears in mangled NTTP value when the original object is so qualified
johelegp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Oct 11 19:52:55 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107222
Bug ID: 107222
Summary: const qualifier appears in mangled NTTP value when the
original object is so qualified
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See https://compiler-explorer.com/z/63f9sxnec.
```C++
struct A { int i; };
union Y { A a; };
constexpr Y make_y(const A a) { return {a}; }
template<auto> struct q { };
template<auto V> constexpr q<V> make_q() { return {}; }
template<auto> void print();
int main() {
constexpr q x = make_q<make_y({1})>();
print<x>();
// +x;
}
```
```
main:
sub rsp, 8
call void print<q<Y{.a=A const{1}}>{}>()
xor eax, eax
add rsp, 8
ret
```
Alternatively, when uncommenting `+x;`:
```
<source>: In function 'int main()':
<source>:10:3: error: no match for 'operator+' (operand type is 'const
q<Y{const A{1}}>')
10 | +x;
| ^~
```
More information about the Gcc-bugs
mailing list