2014-10-30 150 views
0

当在Ubuntu 14.04与-fsanitize铿锵3.5编译MAME/MESS(https://github.com/mamedev/mame/)=功能我得到很多下列错误:-fsanitize = function(UndefinedBehaviorSanitizer)错误实际上是什么意思?

src/lib/util/delegate.h:651:64: runtime error: call to function osd_file_output_callback(_IO_FILE*, char const*, __va_list_tag*) through pointer to incorrect function type 'void (*)(delegate_generic_class *, const char *, __va_list_tag *)' 
/home/notroot/trunk/src/osd/osdcore.c:14: note: osd_file_output_callback(_IO_FILE*, char const*, __va_list_tag*) defined here 

src/lib/util/delegate.h:649:42: runtime error: call to function rom_exit(running_machine&) through pointer to incorrect function type 'void (*)(delegate_generic_class *)' 
/home/notroot/trunk/src/emu/romload.c:1514: note: rom_exit(running_machine&) defined here 

我真的不明白,因为如果有什么这些错误的意思函数签名不匹配我会希望应用程序在某个时刻崩溃。到目前为止,没有人能够向我解释这个错误实际上意味着什么或者为什么这是工作。

回答

0

我真的不明白这些错误是什么意思,因为如果函数签名不匹配,我会期望应用程序在某个时刻崩溃。

而这就是未定义行为的危险。这确实意味着函数签名不匹配。这并不意味着它会崩溃,或者等到崩溃之前看到的老板,或者破坏堆栈或什么东西。它甚至可能变成今天完全不可观测的,但不是未来版本的编译器(或旧版本)。未定义的行为就是这样。你不能从观察到的行为中得出未定义行为的结论。

在你的情况下,它不会崩溃,因为指向_IO_FILE的指针和指向delegate_generic_class的指针的大小相同,并且它们在ABI中没有什么特别的地方(假设x86-64 linux)。

+0

啊,所以这个警告是关于在函数签名中强制执行“类型安全性”,只要它们的大小匹配,这是不必要的。我现在明白了 - 有道理。 – Quotenjugendlicher 2014-11-29 14:23:48

相关问题