On Fri, Jun 20, 2014 at 08:19:34PM +0200, Matthieu Herrb wrote: > > On Jun 18, 2014, at 1:46 PM, Matthieu Herrb wrote: > > > Hi > > > > > > the simple c++ program below dumps core on armv7 (an iMX6 Sabre lite > > > board in my case): > > > > > > #include <iostream> > > > > > > using namespace std; > > > > > > int > > > main(int arg? char *argv[]) > > > { > > > cout ? "Hello World!" ? endl ; > > > return 0; > > > }
This isn't a very helpful reply, but gives more data-points, which might be helpful. $ sysctl kern.version kern.version=OpenBSD 5.5-current (GENERIC-OMAP) #3: Mon Jun 16 21:01:38 EDT 2014 r...@pandaes.in.nickh.org:/usr/src/sys/arch/armv7/compile/GENERIC-OMAP It seems the returned references from the operator<<() "become" invalid when switching "types". e.g., // does not crash cout << "hi there" << "." << " How are you?\n"; // cout.operator<<("hi there").operator<<(".") // .operator<<(" How are you?\n"); // CRASHES Here V cout << "hi there" << '.' << " How are you?\n"; // cout.operator<<("hi there").operator<<('.') // .operator<<(" How are you?\n"); <-crash // CRASHES HERE V cout << "One, two, three: " << 123 << "\n"; // cout.operator<<("One, two, three: ").operator<<(123) // .operator<<("\n"); <- crash // CRASHES HERE V cout << "One, two, three: " << 123 << 999; // cout.operator<<("One, two, three: ").operator<<(123) // .operator<<(999); <- crash // does not crash cout << "One, two, three: " << 123; cout << "\n"; // does not crash cout << "One, two, three: " << 123; cout << 999; cout << "\n"; Let's examine the output stream reference in gdb with this source: $ cat simple2.cc include <iostream> #include <iomanip> using namespace std; template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& baz(basic_ostream<_CharT, _Traits>& os) { return os; } int main(int argc, char *argv[]) { try { cout << "break on baz:" << baz << 123 << baz; cout << "\n"; } catch (...) { return 1; } return 0; } $ c++ -g -O0 simple2.cc -o simple2 $ gdb ./simple2 GNU gdb 6.3 [...] (gdb) break 10 Breakpoint 1 at 0x90dc: file simple2.cc, line 10. (gdb) r Starting program: /home/sidster/simple2 Breakpoint 1, baz<char, std::char_traits<char> > (os=@0x21380) at simple2.cc:10 10 return os; (gdb) p os $1 = ( std::basic_ostream<char,std::char_traits<char> > &) @0x21380: {<std::basic_ios<char,std::char_traits<char> >> = {<std::ios_base> = { [...] (gdb) c Continuing. Breakpoint 1, baz<char, std::char_traits<char> > (os=@0xbffe3328) at simple2.cc:10 10 return os; (gdb) p os $2 = (std::basic_ostream<char,std::char_traits<char> > &) @0xbffe3328: {Cannot a ccess memory at address 0xfffffff4 Note that on first entrance of break point, ostream ref is good. However, after operator<<(int) for integer "123", the references is somehow "invalid", as seen during second visit to the break point. And, boy building simple stuff like this painfully slow on my BBB. Is this b/c of the uSD or is the CPU just a dog? --patrick > > > sabre% g++ -g -Wall hello.cc > > > sabre% gdb ./a.out > > > GNU gdb 6.3 > > > Copyright 2004 Free Software Foundation, Inc. > > > GDB is free software, covered by the GNU General Public License, and > > > you are > > > welcome to change it and/or distribute copies of it under certain > > > conditions. > > > Type "show copying" to see the conditions. > > > There is absolutely no warranty for GDB. Type "show warranty" for > > > details. > > > This GDB was configured as "arm-unknown-openbsd5.5"... > > > (gdb) r > > > Starting program: /home/matthieu/prog/c++/a.out > > > Hello World! > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > 0x4e3d9934 in std::ostream::flush (this=0x0) at basic_ios.h:308 > > > 308 { return _M_streambuf; } > > > (gdb) bt > > > #0 0x4e3d9934 in std::ostream::flush (this=0x0) at basic_ios.h:308 > > > #1 0x4e3d8944 in std::ostream::operator? (this=Variable "this" is not > > > available. > > > ) at ostream:117 > > > #2 0x00008da4 in main (argc=1, argv=0xbfff9454) at hello.cc:8 > > > (gdb) > > > -- > > > Matthieu Herrb