bool addSigned(int a) { return a + 10 > a; } // UB reported only with -fsanitize=undefined: // UB reported only with -fsanitize=unsigned-integer-overflow:
bool
我试图在一个项目中使用UBSAN,但遇到了一个似乎不可能解决的问题:该项目使用通过共享库实现的插件系统。也就是说,每个插件都提供一个工厂方法,该方法返回带有插件特定派生类的某个抽象类的实例。然而,在使用任何接口方法时,UBSAN抛出member call on address 0x... which does not point to an object of type '...'