const ref
declarations don't result in const
pointers in generated code
#27218
Labels
const ref
declarations don't result in const
pointers in generated code
#27218
In a demo today, @jabraham17 asked a question revealing that when we pass an argument by
const ref
intent, we create a non-const
pointer in the generated C code (and I strongly suspect the same is true in the LLVM back-end as well). The same seems to be true for a standaloneconst ref
declaration. Note that we do check that we don't take a non-constref
to aconst
value, so we are not permitting modifications toconst
things as a result of this (so far as I can determine), but are simply not providing as much semantic information to the back-end C compiler as we could be.I determined this by looking at patterns like:
and finding that:
int64_t*
rather than aconst int64_t*
x
using&x
rather than(const int64_t*)&x
int64_t*
rather thanconst int64_t*
r
is declared to have typeint64_t*
rather thanconst int64_t*
The text was updated successfully, but these errors were encountered: