It does not work well, please take a look at the PixType typedef, it is used to iterate over the image pixels: https://github.com/Itseez/opencv/blob/master/modules/calib3d/src/stereosgbm.cpp#L60
You do not catch any compile time errors because the type is checked during runtime (the line you changed) - it is common way to use cv::Mat class. You do not catch any runtime errors because invalid memory access is not checked on some platforms and in some build configurations. Probably if you try to run debug version of your program or use some tool (e.g. valgrind) to detect memory errors you should see it.
Although, you can try to change it to ushort and recompile OpenCV, than, maybe, it will work fine.