我得到一些“由于优化而暂时不可用的值”问题,但据我所知,我正在编译启用调试。
即我正在使用-g -O0 -fno-inline
标志,所以我不确定为什么仍然会发生这种情况。是我错过了一些标志吗?
编译器是g++-mp-4.6 (GCC) 4.6.3
,操作系统是 OSX 10.6Darwin Palace-of-the-Nine-Moons.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
完整的编译选项适用g++-mp-4.6 -Wall -Werror -Wno-unused -g -O0 -fno-inline -I/usr/local/include -I../allig -std=c++0x -c src/Toolbox.cpp -o o/Toolbox.o
于每个文件。
gdb 会话:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000021
[Switching to process 23874]
0x0000000100035d64 in al_get_bitmap_width ()
(gdb) bt
#0 0x0000000100035d64 in al_get_bitmap_width ()
#1 0x0000000100005e47 in Icon::resize (this=0x101244530, w=<value temporarily unavailable, due to optimizations>, h=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:24
#2 0x0000000100005e1f in Icon::create_icon (this=0x101244530, _icon_size=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:20
#3 0x000000010000ae24 in Icontainer::add_icon (this=0x101244210, tt=0x101244530) at ../allig/Icontainer.cpp:18
#4 0x0000000100002d58 in _al_mangled_main (argc=1, argv=0x7fff5fbff600) at src/mapedit.cpp:202
#5 0x000000010009ff17 in +[AllegroAppDelegate app_main:] ()
#6 0x00007fff82d45114 in __NSThread__main__ ()
#7 0x00007fff81f4afd6 in _pthread_start ()
#8 0x00007fff81f4ae89 in thread_start ()
(gdb) up
#1 0x0000000100005e47 in Icon::resize (this=0x101244530, w=<value temporarily unavailable, due to optimizations>, h=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:24
24 ow=al_get_bitmap_width(icon);
Current language: auto; currently c++
[...]
(gdb) up
#2 0x0000000100005e1f in Icon::create_icon (this=0x101244530, _icon_size=<value temporarily unavailable, due to optimizations>) at ../allig/Icon.cpp:20
20 resize(_icon_size,_icon_size);
(gdb) print _icon_size
$2 = <value temporarily unavailable, due to optimizations>
(gdb) up
#3 0x000000010000ae24 in Icontainer::add_icon (this=0x101244210, tt=0x101244530) at ../allig/Icontainer.cpp:18
18 tt->create_icon(icon_size);
(gdb) print icon_size
$3 = 32 ' '
(gdb) quit
代码片段:
void Icon::resize (unsigned char w, unsigned char h) {
unsigned short ow,oh;
ow=al_get_bitmap_width(icon);
向上
void Icon::create_icon (unsigned char _icon_size) {
resize(_icon_size,_icon_size);
}
向上
int Icontainer::add_icon (Icon *tt) {
int ret=icons.size();
tt->tool=TOOL_TILE;
tt->create_icon(icon_size);
最后在这里图标大小可用。