A
Alex Vinokur
Hi,
I compiled and run the following program
on 2 compilers - HP-UX aCC and IBM xlC,
in 2 modes - No optimiztion and O2.
Program crashed while xlC and O2.
Something wrong with the program?
Thanks.
=== test3.cpp ===
struct Foo
{
int m_l1;
};
char s_array[100];
struct Bar
{
char* m_pCh;
Foo*& m_pFoo;
Bar()
:
m_pCh (0),
m_pFoo (reinterpret_cast<Foo*&> (m_pCh))
{
}
void func()
{
m_pCh = &s_array[0];
m_pFoo->m_l1 = 123;
}
};
int main()
{
Bar bar;
bar.func();
return 0;
}
=================
========= HP-UX, aCC ==========
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
================================
========= AIX, xlC ==========
IBM XL C/C++ Enterprise Edition V8.0 for AIX
Version: 08.00.0000.0014
[using memory image in core]
reading symbolic information ...
Segmentation fault in main at line 22
22 m_pFoo->m_l1 = 123;
(dbx) where
main(), line 22 in "test3.cpp"
(dbx) dump
main(), line 22 in "test3.cpp"
libdebug assertion "(0)" failed at line 688 in
file ../../../../../../../../../../../src/bos/usr/ccs/lib/libdbx/
libdebug/modules/stackdebug/POWER/stackdb_PowerStackFrame.C
bar = warning: Unable to access address 0xf163ad60300c6670 from core
(m_pCh = warning: Unable to access address 0xffffffff from core
(invalid char ptr (0xffffffff)), warning: Unable to access address
0xffffffff from core
m_pFoo = 0xffffffff)
=============================
Alex Vinokur
I compiled and run the following program
on 2 compilers - HP-UX aCC and IBM xlC,
in 2 modes - No optimiztion and O2.
Program crashed while xlC and O2.
Something wrong with the program?
Thanks.
=== test3.cpp ===
struct Foo
{
int m_l1;
};
char s_array[100];
struct Bar
{
char* m_pCh;
Foo*& m_pFoo;
Bar()
:
m_pCh (0),
m_pFoo (reinterpret_cast<Foo*&> (m_pCh))
{
}
void func()
{
m_pCh = &s_array[0];
m_pFoo->m_l1 = 123;
}
};
int main()
{
Bar bar;
bar.func();
return 0;
}
=================
========= HP-UX, aCC ==========
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
aCC test3.cpp
./a.out
aCC -O2 test3.cpp
./a.out
================================
========= AIX, xlC ==========
IBM XL C/C++ Enterprise Edition V8.0 for AIX
Version: 08.00.0000.0014
xlC test3.cpp
./a.out
Segmentation fault (core dumped)xlC -O2 test3.cpp
./a.out
Segmentation fault (core dumped)xlC -g -O2 test3.cpp
./a.out
Type 'help' for help.dbx a.out core
[using memory image in core]
reading symbolic information ...
Segmentation fault in main at line 22
22 m_pFoo->m_l1 = 123;
(dbx) where
main(), line 22 in "test3.cpp"
(dbx) dump
main(), line 22 in "test3.cpp"
libdebug assertion "(0)" failed at line 688 in
file ../../../../../../../../../../../src/bos/usr/ccs/lib/libdbx/
libdebug/modules/stackdebug/POWER/stackdb_PowerStackFrame.C
bar = warning: Unable to access address 0xf163ad60300c6670 from core
(m_pCh = warning: Unable to access address 0xffffffff from core
(invalid char ptr (0xffffffff)), warning: Unable to access address
0xffffffff from core
m_pFoo = 0xffffffff)
=============================
Alex Vinokur