I see no reason for it to seg fault. Perhaps there's some undefined operation in "main", which you don't show?