cppfront
cppfront copied to clipboard
[BUG] Forwarding a function argument has different behaviour compared to C++ syntax 1
trafficstars
While in C++ syntax 1 constness is preserved when forwarding an argument to a function, in C++ syntax 2 the constness seems to be removed.
Syntax 1
void f(auto&& p) {
p += 1;
}
void g() {
{
const auto p = 1;
//f(p); // this does not compile
}
{
auto p = 1;
f(p);
}
}
Syntax 2
f : (forward p : int) = {
p += 1;
}
g : () = {
{
const p = 1;
f(p); // this compiles
}
{
p = 1;
f(p);
}
}
Shouldn't they both fail to compile?