[FFmpeg-devel] [PATCH] avfilter/showcqt: BASEFREQ and ENDFREQ cast to double

Muhammad Faiz mfcc64 at gmail.com
Mon Nov 30 17:49:53 CET 2015


On Mon, Nov 30, 2015 at 11:09 PM, Nicolas George <george at nsup.org> wrote:
> Le decadi 10 frimaire, an CCXXIV, Muhammad Faiz a écrit :
>> double basefreq = BASEFREQ, endfreq = ENDFREQ;
>> if (basefreq == BASEFREQ && endfreq == ENDFREQ)
>>     printf("equal\n");
>> else
>>     printf("inequal\n");
>>
>> I try with gcc -std=c89 / -std=c99 on mingw 32-bit
>> the result is inequal.
>
> That looks like a compiler bug. Could you post the generated assembly code,
> with and without the cast? (and with just one comparison, no need to make
> things complicated)

#include <stdio.h>

#define BASEFREQ        20.01523126408007475

double basefreq = BASEFREQ;

int
main(int argc, char** argv)
{
    if (basefreq == BASEFREQ)
        printf("equal\n");
    else printf("inequal\n");
    return 0;
}


gcc -c -std=c89 -O2

without cast:
00000000 <_main>:
   0: 55                   push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 83 e4 f0             and    $0xfffffff0,%esp
   6: 83 ec 10             sub    $0x10,%esp
   9: e8 00 00 00 00       call   e <_main+0xe>
   e: dd 05 00 00 00 00     fldl   0x0
  14: db 2d 10 00 00 00     fldt   0x10
  1a: d9 c9                 fxch   %st(1)
  1c: df e9                 fucomip %st(1),%st
  1e: dd d8                 fstp   %st(0)
  20: 7a 02                 jp     24 <_main+0x24>
  22: 74 10                 je     34 <_main+0x34>
  24: c7 04 24 06 00 00 00 movl   $0x6,(%esp)
  2b: e8 00 00 00 00       call   30 <_main+0x30>
  30: 31 c0                 xor    %eax,%eax
  32: c9                   leave
  33: c3                   ret
  34: c7 04 24 00 00 00 00 movl   $0x0,(%esp)
  3b: e8 00 00 00 00       call   40 <_main+0x40>
  40: eb ee                 jmp    30 <_main+0x30>


with cast:
00000000 <_main>:
   0: 55                   push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 83 e4 f0             and    $0xfffffff0,%esp
   6: 83 ec 10             sub    $0x10,%esp
   9: e8 00 00 00 00       call   e <_main+0xe>
   e: dd 05 00 00 00 00     fldl   0x0
  14: dd 05 10 00 00 00     fldl   0x10
  1a: d9 c9                 fxch   %st(1)
  1c: df e9                 fucomip %st(1),%st
  1e: dd d8                 fstp   %st(0)
  20: 7a 02                 jp     24 <_main+0x24>
  22: 74 10                 je     34 <_main+0x34>
  24: c7 04 24 06 00 00 00 movl   $0x6,(%esp)
  2b: e8 00 00 00 00       call   30 <_main+0x30>
  30: 31 c0                 xor    %eax,%eax
  32: c9                   leave
  33: c3                   ret
  34: c7 04 24 00 00 00 00 movl   $0x0,(%esp)
  3b: e8 00 00 00 00       call   40 <_main+0x40>
  40: eb ee                 jmp    30 <_main+0x30>


without cast with -std=gnu89:
00000000 <_main>:
   0: 55                   push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 83 e4 f0             and    $0xfffffff0,%esp
   6: 83 ec 10             sub    $0x10,%esp
   9: e8 00 00 00 00       call   e <_main+0xe>
   e: dd 05 00 00 00 00     fldl   0x0
  14: dd 05 10 00 00 00     fldl   0x10
  1a: d9 c9                 fxch   %st(1)
  1c: df e9                 fucomip %st(1),%st
  1e: dd d8                 fstp   %st(0)
  20: 7a 02                 jp     24 <_main+0x24>
  22: 74 10                 je     34 <_main+0x34>
  24: c7 04 24 06 00 00 00 movl   $0x6,(%esp)
  2b: e8 00 00 00 00       call   30 <_main+0x30>
  30: 31 c0                 xor    %eax,%eax
  32: c9                   leave
  33: c3                   ret
  34: c7 04 24 00 00 00 00 movl   $0x0,(%esp)
  3b: e8 00 00 00 00       call   40 <_main+0x40>
  40: eb ee                 jmp    30 <_main+0x30>

without cast and use -std=c89, gcc uses fldt instead of fldl


More information about the ffmpeg-devel mailing list