Panic when calling `t.Elem()` when `t.Kind() == cc.Ptr`
Section from the cc's type.go:
// Elem returns a type's element type. It panics if the type's Kind is
// valid but not Array or Ptr.
I am running into a type where it is a pointer
(to nothing).
My code is running into this at line 24228 at sqlite3.c:
if( p && sqlite3GlobalConfig.m.xFree==sqlite3MemFree ){
The type is created from calling n.Promote()
on the quality expression sqlite3GlobalConfig.m.xFree==sqlite3MemFree
. Both sides should have type void (void*)
so that should also be the promoted type (I think).
It is suprisingly easy to reproduce:
void (*x)(void*);
static void sqlite3MemFree(void *pPrior){}
int main () {
if (x==sqlite3MemFree){
return 1;
}
return 0;
}
This gives n.Promote()
which is a pointer that doesn't point.
At the very least, I should always be able to call t.Elem()
when t.Kind() == cc.Ptr
.