constの話で盛り上ってるからついでに聞きたいんだけど

struct X {
int *p;

void test(int x) const
{
*p = x;
}
};

こう書くとconst指定してるのにオブジェクトの内容が変化してる
これって合法なの?