On Fri, Oct 13, 2006 at 03:32:06PM +0200, Marco Gubernati wrote: > Well, my program works correctly if compiled, for example, with > gcc-3.3.5 (on SuSe and Debian) or gcc-3.4.3 (on Ubuntu). If compiled > with gcc-4.1.0 > (on the latest SuSe 10.1 release) (exactly the same code) the program > crashes when calls the gtk_text_buffer_insert, with the error Xlib: > unexpected asynch reply, which I know was > a problem of old versions of Xlib with multithreading. Well, any idea, > any knew optizimation features of gcc-4.1.0 that may cause a thing like > that??
While a compiler bug is possible, with these kinds of things other causes are more likely: undefined behavior (e.g. reading uninitialized memory) or an aliasing issue (gcc 4.x does more aggressive optimization based on the C language rules about which types can be addressed by which types of pointers). I'd suggest checking your program with a tool like valgrind (when compiled with a compiler that makes the program work) to make sure that there aren't things like uninitialized memory. You could also try the -fno-strict-aliasing flag of gcc 4.1.0, to see if that's an issue. You can then try to narrow down the bug (whether in your code, or the compiler) by compiling some object files with one compiler and some with another.