Hi all, Max found something that is important to know. Apparently, gcc accepts "false" as a value for a pointer. So it is possible to write: test_function(Test *t) ... test_function(false); without triggering a compiler warning/error. This hid a problem after refactoring a function method, resulting in a crash. See the mail below for more details. Cheers, Johan -----Original Message----- From: Maximilian Albert [mailto:Anhalter42@...173...] Sent: maandag 8 september 2008 15:13 To: Engelen, J.B.C. (Johan) Subject: Re: active_desktop removals J.B.C.Engelen@...1578... schrieb:
We should check this, this is really bad compiler behaviour!
I just wrote a simple test program (attached below). It works fine as is, but when I replace the line test_function(t); with test_function(false) there is a runtime crash. However, even when compiling with -Wall there is no warning whatsoever. Interestingly, when I replace false with true in the function call, the code doesn't compile any more. But I'd think that false is just as well recognized as a boolean value as true is. Hmm, I think I will report this upstream on the gcc mailing list. Max =================================== #include <iostream> using namespace std; class Test { public: Test() {} void print() { cout << "Hello, world!" << endl; } }; void test_function(Test *t) { t->print(); } int main() { Test *t = new Test(); test_function(t); // replace t with false to trigger a runtime crash delete t; }