A testcase for x86 architecture (Intel Core i5 CPU here): 1) Download http://sourceforge.net/projects/faac/files/faad2-src/faad2-2.6/faad2-2.6.1.tar.gz/download 2) Build it using these commands perl -pi -e 's|dnl AC_PROG_CXX|AC_PROG_CXX|' configure.in autoreconf -vif configure --disable-static using GCC 4.2.4 and GCC 4.4.x 3) faad binary compiled with GCC 4.4.x will fail to properly decode some AAC files (a sample file can be downloaded here http://bugzilla.mplayerhq.hu/attachment.cgi?id=651 ) faad -o outfile.wav out.aac ... Decoding out.aac took: 0.21 sec. 285.83x real-time. (GCC 4.2.x) Decoding out.aac took: 1.55 sec. 38.72x real-time. (GCC 4.4.x) So, we have two bugs here: 1) faad2's AAC decode algorithm fails to work correctly under GCC 4.4.x (even with gcc -O2 -march=i686). 3) faad2's AAC decode algorithm compiled with GCC 4.4.x works an order of magnitude slower than the same code code compiled using GCC 4.2.x.
faad2 2.7.0 exhibits the same misbehavior, you can download it here: http://downloads.sourceforge.net/faac/faad2-2.7.tar.bz2 No extra commands are required for compilation, just ./configure && make --- P.S. You may want to use ./configure --enable-static --disable-shared in order to get a single binary which doesn't use any external libraries (thus it will be easier to verify the bug).
Created attachment 21368 [details] faad2 2.7.0 complete sources with -save-temps Complete sources with -save-temps for GCC 4.2.4 and GCC 4.4.4. The same compilation flags: -march=i686 -O2 -pipe -save-temps
I've just tested GCC 4.5.1 and it also miscompiles the source code.
Created attachment 21369 [details] faad2 2.7.0 complete sources with -save-temps for GCC 4.5.1
I've found the culprit (or better say mplayer developer hinted), it is -fstrict-aliasing optimization. With -fno-strict-aliasing GCC 4.4.x and 4.5.x produce proper code. Please, advise.
Why CC me? I have no clue about faad2, the strict-aliasing thing hints at errors in faad2, not gcc.
(In reply to comment #6) > Why CC me? I have no clue about faad2, the strict-aliasing thing hints > at errors in faad2, not gcc. > Richard, I don't know who is who amongst GCC developers, but you are a prominent person, so I thought you know someone who can help shed light on this issue. Like I said GCC 4.2.x has no problems compiling this library, so I have no idea who to blame and who else I should get in touch with.
> Like I said GCC 4.2.x has no problems compiling this library, so I have no idea > who to blame and who else I should get in touch with. I would get into contact with the developers of the library first. Yes GCC has some bugs but the library could have a bug still. Since the problem disappreas with -fno-strict-aliasing that normally points at a bug in the library. In that it does not follow the C/C++ alisaing rules.
The culprit is the ic_predict.c file. When I compile it with -fno-strict-aliasing (while everything else is being compiled with -fstrict-aliasing) libfaad works correctly. These are the warnings which I get from GCC: ic_predict.c: In function 'flt_round': ic_predict.c:58: warning: dereferencing type-punned pointer will break strict-aliasing rules ic_predict.c:58: warning: dereferencing type-punned pointer will break strict-aliasing rules ic_predict.c:58: warning: dereferencing type-punned pointer will break strict-aliasing rules ic_predict.c:60: warning: dereferencing type-punned pointer will break strict-aliasing rules ic_predict.c: In function 'ic_prediction': ic_predict.c:78: warning: dereferencing pointer 'tmp' does break strict-aliasing rules ic_predict.c:77: note: initialized from here ic_predict.c:78: warning: dereferencing pointer 'tmp' does break strict-aliasing rules ic_predict.c:77: note: initialized from here ic_predict.c:78: warning: dereferencing pointer 'tmp' does break strict-aliasing rules ic_predict.c:77: note: initialized from here ic_predict.c:78: warning: dereferencing pointer 'tmp' does break strict-aliasing rules ic_predict.c:77: note: initialized from here ic_predict.c:78: warning: dereferencing pointer 'tmp' does break strict-aliasing rules ic_predict.c:77: note: initialized from here ic_predict.c:78: warning: dereferencing pointer 'tmp' does break strict-aliasing rules ic_predict.c:77: note: initialized from here Maybe GCC developers could devise a patch for this file because http://www.audiocoding.com/faad2.html site seems to be dead.
Not a gcc bug.
(In reply to comment #9) > Maybe GCC developers could devise a patch for this file because > http://www.audiocoding.com/faad2.html site seems to be dead. > (In reply to comment #10) > Not a gcc bug. > FAAD developers don't answer my e-mails, so what I can do? Resort to compile FAAD library using a specially compiled GCC? What about other less experienced users? There just a few warnings which I suppose can be easily resolved ...