code:Compile and link like so:#include <iostream>
class TestClass {
public:
TestClass ();
private:
double* testarray;
};
TestClass::TestClass () {
testarray = new double[40];
}
int main (int argc, char** argv) {
return 0;
}
code:This program, which does absolutely nothing, manages to segviol; here's the gdb trace:g++ -Wall -fPIC -O2 -g -pg -c -o Test.o Test.cc
g++ -Wall -fPIC -O2 -g -pg -pthread Test.o -o blah
code:Any of the following will fix the crash:Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1218574944 (LWP 27213)]
0x0076e2c7 in _int_free () from /lib/tls/libc.so.6
(gdb) bt
#0 0x0076e2c7 in _int_free () from /lib/tls/libc.so.6
#1 0x0076d278 in free () from /lib/tls/libc.so.6
#2 0x007dac28 in _mcleanup () from /lib/tls/libc.so.6
#3 0x007268f3 in exit () from /lib/tls/libc.so.6
#4 0x007117fc in __libc_start_main () from /lib/tls/libc.so.6
#5 0x0804853d in _start ()
quote:Yes, I did realise that, but it was a 20% improvement, not a two-orders-of-magnitude one.
Lots of asserts is why DNDEBUG made it so much faster.