gcc 4.2 branch and gcc 4.3 SVN snapshot seems to miscompile MPlayer's mp_msg.c resulting in a crash. gcc 3.4.6 is ok. During compilation no warning is issued. Gcc tested is : Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/cartman/gcc_4.2 --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --disable-nls Thread model: posix gcc version 4.2.0 20061217 (prerelease) I will attach two files: mp_msg_compiled_with_O1_crashes.i produced with : cc -O1 -Wdeclaration-after-statement -march=pentium-m -mtune=pentium-m -pipe -ffast-math -fomit-frame-pointer -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I/usr/include -I/usr/include/ -I/usr/include/SDL -D_REENTRANT -I/usr/include -I/usr/include/dvdnav -I/usr/include/freetype2 -I. -I./libavutil -I./libavcodec -c -save-temps mp_msg.c mp_msg_compiled_with_O0_works.i produced with: cc -O0 -Wdeclaration-after-statement -march=pentium-m -mtune=pentium-m -pipe -ffast-math -fomit-frame-pointer -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I/usr/include -I/usr/include/ -I/usr/include/SDL -D_REENTRANT -I/usr/include -I/usr/include/dvdnav -I/usr/include/freetype2 -I. -I./libavutil -I./libavcodec -c -save-temps mp_msg.c
Created attachment 12823 [details] mp_msg.c compiled with -O0
Created attachment 12824 [details] mp_msg.c compiled with -O1
Valgrinding the crashing mplayer shows: ==5836== Invalid read of size 1 ==5836== at 0x401E776: strlen (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so) ==5836== by 0x4B4049E: fprintf (in /lib/libc-2.3.6.so) ==5836== by 0x81098CF: open (vf_ass.c:395) ==5836== by 0x80DC4F6: vf_open_plugin (vf.c:466) ==5836== by 0x80831F6: reinit_video_chain (mplayer.c:3321) ==5836== by 0x8086699: main (mplayer.c:4517) ==5836== Address 0x5248003E is not stack'd, malloc'd or (recently) free'd which shows line 182 in mp_msg.c which is something like: fprintf(stream, "\033[%d;3%dm%9s\033[0;37m: ",c2>>3,c2&7, mod_text[mod]); If I replace mod_text[mod] with "foo" it doesn't crash anymore.
There is no obvious what is wrong from the tree dumps.
I tried to follow http://gcc.gnu.org/bugs.html#need . Anything else I should provide?
Another MPlayer bug exposed by gcc, sorry guys!