[Bug c++/127196] [contracts] redeclaration of function with type dependent param used in postcondition accepts non-const param
waffl3x at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Sep 5 00:25:40 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127196
--- Comment #1 from Waffl3x <waffl3x at gcc dot gnu.org> ---
https://godbolt.org/z/T76asK9nY
```
template<typename T>
bool g();
template<>
bool g<int>() { __builtin_printf("Shouldn't happen"); return true; }
template<>
bool g<const int>() { return true; }
template<typename T>
void f0(T a)
post(g<decltype(a)>());
template<typename T>
void f0(T const a) {}
template void f0<int>(int);
template<typename T>
void f1(T const a)
post(g<decltype(a)>()) {}
template void f1<int>(int);
int main()
{
f1(42);
f0(42);
}
```
Unfortunately this is not merely a diagnostic issue.
I'm working on this.
More information about the Gcc-bugs
mailing list